943,990 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 115932
  • JSP RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 14th, 2007
0

How to redirect a page in JSP

Expand Post »
hi all.

I have a form in page1.jsp. the action for that form submit is in page2.jsp

so I want to just come back to the page1.jsp after processing the request.(reload the first page again)

so in page2.jsp, how can i redirect the display page to the page1.jsp


here I tried to used the "<jsp:forward page=" tag
but my request is not to forward only the request object
I wanna redirect the page

thanks...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Feb 14th, 2007
0

Re: How to redirect a page in JSP

instead of JSP use servlet, so from page1.jsp send form to servlet where you validate and process the form and after that you can get back to page1.jsp
Question is why do you want to go back? It is because of error which is OK, or some other reason which is unclear to me...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,658 posts
since Dec 2004
Feb 14th, 2007
0

Re: How to redirect a page in JSP

Last edited by nikkiH; Feb 14th, 2007 at 12:20 pm.
Reputation Points: 13
Solved Threads: 4
Junior Poster in Training
nikkiH is offline Offline
79 posts
since Dec 2006
Feb 14th, 2007
0

Re: How to redirect a page in JSP

NEVER use JSP scriptlets. They are the single worst part of the system and should never have been introduced.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Feb 14th, 2007
0

Re: How to redirect a page in JSP

Please share the non-scriplet way for us uneducated folks.
Reputation Points: 13
Solved Threads: 4
Junior Poster in Training
nikkiH is offline Offline
79 posts
since Dec 2006
Feb 14th, 2007
0

Re: How to redirect a page in JSP

here i wanna add some data to the database and show the first page again to add another data.

so the request processing task is done in the page2.jsp . the form is included in page1.jsp
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Feb 15th, 2007
0

Re: How to redirect a page in JSP

Click to Expand / Collapse  Quote originally posted by rpjanaka ...
here i wanna add some data to the database and show the first page again to add another data.
so the request processing task is done in the page2.jsp . the form is included in page1.jsp
OK thas fine if you want to go back to page1 for more data, but you shoudn't connect to database and process request in JSP, you should do it in servlet. That is what servlets are build for
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,658 posts
since Dec 2004
Feb 15th, 2007
0

Re: How to redirect a page in JSP

Click to Expand / Collapse  Quote originally posted by nikkiH ...
Please share the non-scriplet way for us uneducated folks.
Any decent book about JSP will teach you to use JSTL and/or JSF instead of scriptlets.

Of course many books you get cheap or find pirated online are old ones from before JSTL even existed, or written by people who don't care about teaching things properly but only want to get rich quick selling books to schools.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Feb 15th, 2007
-1

Re: How to redirect a page in JSP

That's great, but since you're trying to teach us how NOT to use scriptlets, I'd love to know the right way to do this.

<%
response.sendRedirect("someUrl");
%>

Please share.
I'm much more a C# person than Java these days and the Java I did do was on an old crappy server that didn't fully support JSTL, so I have no idea how else you would do this. This is what Sun had on its site. Please tell me the better way to do this so I know for future reference.
Last edited by nikkiH; Feb 15th, 2007 at 4:34 pm.
Reputation Points: 13
Solved Threads: 4
Junior Poster in Training
nikkiH is offline Offline
79 posts
since Dec 2006
Feb 16th, 2007
0

Re: How to redirect a page in JSP

Do NOT do that in a JSP, use a servlet...
How hard can it get.

JSP are for PRESENTATION only, NEVER for application flow control or business logic.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: How to insert data into database?
Next Thread in JSP Forum Timeline: Session.isNew() problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC