help with JSP Forward !!!
I have 3 pages ...1) index.jsp 2) Forward.jsp 3) welcome.jsp
I have 2 fields in the index.jsp once upon filling & hit submit it has to to go Forward.jsp page...in the Forward.jsp..i have coded only one tag with
<jsp:forward page="welcome.jsp" />
I have one question...once the page comes to Forward page...will it display the contents of the Welcome .jsp in the same page itself...or it will go to Welcome.jsp page..
As i saw it will display the contents of Welcome.jsp page in itself...
Please let me know...
Regards
Gnanesh
[598 byte] By [
gnanesh2] at [2007-9-26 3:52:46]

jsp:forward is a server-side operation.If the form action for submit in index.jsp is Forward.jsp, then after submit, the browser's location will still be showing that it(i.e. the browser) accessed Forward.jsp and not welcome.jspIs that what you wanted to know ?
Didnot really understood ur question what do u mean by
"i saw it will display the contents of Welcome.jsp
page in itself..."
Answer is no your request is passed to Welcome.jsp
this tag is diffrent than what include does
Is this what u are wanting to know ?
Thanks
Sampath ..
The result will be the same as if you posted the form directly to welcome.jsp.
my question is
once i log in to index.jsp page ..from there it takes to Forward.jsp page...in this page i am using
<jsp:forward page=welcome.jsp />..
now may i know if the location page changes to Welcome.jsp page or it will remain in Forward.jsp page...
but i am getting the contents of Welcome.jsp in Forward.jsp..
i hope this will clear ur question...
Rgds
gnanesh
What do you mean by "getting the contents of Welcome.jsp in Forward.jsp"?
Do you mean that the address bar on your browser says Forward.jsp, but the page is Welcome.jsp? That's what you should get. If that's the problem, read this:
http://forum.java.sun.com/thread.jsp?forum=45&thread=156323
hi
when u write code <jsp:forward page=welcome.jsp />..
control will be passed to welcome.jsp from forward.jsp and contents of welcome.jsp will be displayed but it is not like contents of welcome.jsp is overwrittens/included in forward.jsp
If u want contents of welcome.jsp to be included in forward.jsp then write..
<jsp:include page=welcome.jsp />..
I understand your question only because I have a set up totally identical to yours. The thread Matt suggested does explain the situation (i.e. the server passed control to another page but the client doesn't know that), but doesn't necessarily give a good solution a problem that you may have, and that I do have:
If the user sees the welcome page, and for some reason decides to "reload", the forward page is re-executed, even though it has done its job. This could be a problem for session management if you specifically don't want that job being done twice in a session. Now you could hack around that, but I'd really rather see a neat solution. Is there one?
When the user reloads/refreshes a page, the same request gets sent.
If you want to stop the Forward page from being executed a second time round, then either use a client-side redirect in place of the server-side one, or add something to the client's session / create a cookie the first time the client requests the Forward page, and from then on, every time it gets requested you know that it already has been and don't perform all the processing. If there's only one entry point to the site, the existence of a session is enough.
> If you want to stop the Forward page from being
> executed a second time round, then either use a
> client-side redirect in place of the server-side one,
You mean using this instead of <jsp:forward>?
response.sendRedirect(
response.encodeRedirectURL("welcome.jsp"));
If so, and if it works, cool, looks better to me. And it's neater than cookies.