This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes jsp:forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp:forward" Watch "jsp:forward" New topic
Author

jsp:forward

Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Hi Friends,
I need an immediate clarification. My jsp program uses a session. I want to redirect the page to a html page when the session times out. but when I give jsp:forward, it throws an exception saying that "cannot clear JspWriter buffer. Already written source ... " and it does not re direct the page.
Please help.
Thanks,
Prabhu.V.C
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Prabhu
I guess the problem is with your buffer attribute of the page directive.Try increasing the buffer size of the current.
Regards
sanj
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
I don't know if this is the case, but I remember a problem I had early on in my professional Servlet/JSP experience in which I could not forward a POST to a satic HTML page. A GET was OK...


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338
Prabhu
As always, a little code goes a long way. People could give you a better answer if they know what your code looks like.
The jsp:forward is passing the request and response objects to the new page using the same method as the original request. As Tony said, static html files cannot handle POST requests. One work around is to rename the .html file to .jsp, this will give the same behavior for both GET or POST.
There might be another problem with your design. Http is based on requests from the client. You can't have the page change in real time because something expired on the server. The request to change must come from the client. I think commonly people use response.sendRedirect() on the next client request, after the session has expired. (You could do some funky stuff calculating when the session would expire and setting refresh headers, but the request is still really being generated from the client)
regards,
Andrew


!_I_Know_Kung_Fu_!
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
Why not use some (lowly) javascript?
You could set a function in your page to count the time and when your limit is reached to redirect using:
location.href='newpage.html';
Here's an example you can use as a template.

Hope that helps,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Thanks everybody for your replies ....
I rectified the problem i had mentioned about. I had included a stylesheet prior to the <jsp:forward> being given. I dont know the cause of the problem, but when I shifted the <include> directive after the <jsp:forward> it is now working fine.
Thanks again.
If any ou U friends can enlighten me as to reason of the error, it would be very helpful.
Thanks,
Prabhu.V.C

------------------
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI Prabhu,
You got the solution because after a <jsp:include> you can't use <jsp:forward>, because the buffer flushes before processing the include.
If it were necessary to leave them in the order they were in before, then changing the <jsp:include> action for a <%@include %> directive would solve your problem.
Bye,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Thanks yet again for ur prompt replies.
Bye,
Prabhu.V.C

------------------
 
Don't get me started about those stupid light bulbs.
 
subject: jsp:forward
 
Similar Threads
problem passing request to servlet
problem in value retrieve at other page
JSP not cached using jsp:forward from it
error in jsp(please help)
Need help writing LoginCheck.jsp page