aspose file tools*
The moose likes Servlets and the fly likes request is not forwarding..help me out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

request is not forwarding..help me out

Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
hi all
I have a saved some value in session like connection object at the time of login.. but after visiting some time I logout and now my session has been invalidate then the resquset should be forwarded to the relogin page... if check it in the following manner..
if(session.getValue("ISEXPIRED")==null){
System.out.println("Forwarding request....");
res.sendRedirect("relogin.jsp?param=close");
System.out.println("It should not be printed...");
}
but instead of forwarding request requset the message "It should not be printed..." is get printed..
plz sugeste me ...


thankx
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
do a requestDispatcher.sendForward() instead.
sendRedirect does not take immediate effect. It will tell the browser to submit a new request for the redirection resource AFTER the service method of the servlet returns.
In other words, you need to place a return statement after a redirection to force the servlet to complete the response.


42
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hello,

Is there any sendForward() method is RequestDispatcher Interface. I think it should be forward(..).

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
yes, my brain wasn't yet fully awake
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

if(session.getValue("ISEXPIRED")==null){

Also, getValue has been deprecated, use getAttribute instead.
[ February 02, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
THANKS ALL OF YOU..
I HAVE USED requestDispatcher AND NOW ITS WORKING FINE...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request is not forwarding..help me out
 
Similar Threads
Can I use object in JSP which is created in servlet?
Session and RequestDispatcher question
Data Entry Flow Servlet
IllegalStateException: Cannot forward a response that is already committed
how to create a session