[B][U]<td><a href="inbox.jsp" ><%=rs.getString(1)%></a></td>[/U][/B]

See lines in Bold.....after i click it has to set session variable with value reterived from <%=rs.getString(1)% >based on which i am going to display particular contents in redirected page

Edited by nHulk: to make it easy to understand

6 Years
Discussion Span
Last Post by jalpesh_007

Delete everything you have done because they are wrong.

From the code, are you saying that you have a ResultSet in the jsp so you are calling the database from inside a jsp? That is wrong. Create a method, execute the query inside that method and return an array or list of objects that you created with the data from the database. Then call that method from the jsp.

Also are you saying that instead of sending things through the request, you put them in the session! Never put things in the session unless it cannot be avoided. It should be used only for saving the username for example after the log in.
If you want to send something after clicking the link, then set it as a parameter at the url:

<a href="inbox.jsp?param1=<%=var1%>&param2=<%=var2%>&param3=<%=var3%>" >Aaaaa</a>

And at the inbox.jsp:

String param1 = request.getParameter("param1");

Also don't put/send things through jsp using the session. Have you ever submitted a form? That is how you need to send data from one page to the other, through the request.
The session is used only if you want a value to be visible from all of your pages and you don't want to keep on sending it from page to page.

Edited by javaAddict: n/a


hi, In my project i am getting the object of session from a servlet to next jsp. but on that jsp there is a hyperlink to another jsp. when i click on that jsp,i do not get my session object active. What should i do?


can you please post your code which is related to
1.the jsp where you are getting the session scoped variable and navigating to next jsp.
2. the second jsp where you are retrieving again the same session scoped variable.

Edited by subramanya.vl


i think you ahve to look at this:

<a href="X.jsp?category=Sports"><img src="categoryOne.gif" /></a>

<&#37; String category = request.getParameter( "category" ); %>
(if you really want category as a session attribute, promote it at this point: )
session.setAttribute( "category", category );

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.