Dharmesh Shah

Greenhorn
+ Follow
since Oct 01, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Dharmesh Shah

Correction it is request.setAttribute() and not response.setAttribute()
Mindi, if you havent pulled it yet, email me, I have similar code and would send you those files. Good Luck!
23 years ago
Hey Mandy,
I believe it should not be too difficult.
From the first page you may take the form data to your servlet/JSP and then populate your object(s) with the data received from the request object, now you can either put this object(s) in session or you may pass your object(s) with the response to the next jsp page using response.setAttribute(). In the latter case you will have to do request.getAttribute() and then response.setAttribute() in second JSP, but if u decide to put you objects in session then u can just get it back when u are ready to put them in the database, just make sure you specifically unset the session attribute after u insert your data in the database.
23 years ago
Attached is the JSP code i have.
I am not sure but it looks like the problems could be in Tomcat configuration, because it seems to display the same page even if I restart the server. For example if I login as user USER-A and refresh following page, it would display USER-A, now if i restart the server and login as USER-B and then call following page, it would still display USER-A until I refresh the page.
I have the default configuration for tomcat and have not made any modifications.

<% HttpSession ses = request.getSession();
if(ses != null){
user u = (user)ses.getAttribute("theUser");
if(u != null)
{ %>
<input type="hidden" name="userId" value=<%= u.getUserId() %> ><%= u.getUserId() %>
<input type="hidden" name="userName" value=<%= u.getUserName() %> ><%= u.getUserName() %>
<% }
else
{
%>
Please log in.
<%}
} %>
23 years ago
Am having trouble with getting correct values from the objects retrieved from session in the JSP.
Am instantiating a user object in the login servlet and storing in session. The user object is access from the session in the JSP and then the getUserName() is called on the user.
The problem is that when the jsp page is called, it does not get the user name, but if I click refresh on the browser then it would display the user name.
if anyone has fix for this, let me know. Thanks!
PS: am using Tomcat JSP/Servlet engine
23 years ago