Hi,
I seem to have tied myself in circles posting (using POST) a users password from a
JSP page to a
servlet.
If the posted password matches what is listed in the servlet then the inbound ServletData(com.javaranch.common.ActionServlet) object is opened and the HttpServletResponse object is extracted, has a cookie added to it and then is used to form part of a new ServletData object passed to a newly created 'action' within the same servlet.
NOT using forward() or redirect(). The code should make this a bit clearer.
This new doAction() method should then check to see that the incoming ServletDataObject has the correct cookie for access, then write out a jsp page if so.
What I am finding is the first time I click 'submit' on the password page that it doesn't send me to the error page, but neither do I get sent to the new JSP. All it does is add the Jsession id to the URL, the second time I hit submit it is ok.
I found this post
https://coderanch.com/t/362557/Servlets/java/cookie-questions But am still not clear what is going on.
The login jsp is :-
In the servlet I have
Which leads to :-
Calling new ListVideos().doAction(newServlet). Usually called from inbound post requests from client. In this case called from servlet itself, is this acceptable?
So first time I submit the login JSP
Orion server log outputs
127.0.0.1 - - [01/Apr/2008:19:41:23 +0000] "POST /videos2/servlet/VideoServlet;jsessionid=PEEEHHKHLHJB HTTP/1.1"
200 502 second time
127.0.0.1 - - [01/Apr/2008:19:42:20 +0000] "POST /videos2/servlet/VideoServlet HTTP/1.1"
200 694 Checking in firefox and opera I can see the correct cookie has been created and it allows me to do other things without logging back in,
I have the sinking feeling I have missed the point.
It was supposed to be an exercise in MVC Model 2.
but never mind.
cheers
Nick
[ April 01, 2008: Message edited by: Nick Fernandez ]
[ April 02, 2008: Message edited by: Marilyn de Queiroz ]