| | |
How to redirect a page in JSP
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2006
Posts: 68
Reputation:
Solved Threads: 0
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...
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...
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...
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...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Use a scriptlet and response.SendRedirect()
http://java.sun.com/products/jsp/tag...ref11.fm5.html
http://java.sun.com/j2ee/1.4/docs/ap...tResponse.html
http://java.sun.com/products/jsp/tag...ref11.fm5.html
http://java.sun.com/j2ee/1.4/docs/ap...tResponse.html
Last edited by nikkiH; Feb 14th, 2007 at 12:20 pm.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
Please share the non-scriplet way for us uneducated folks.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
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
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
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.
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
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.
<%
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.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
![]() |
Similar Threads
Other Threads in the JSP Forum
- Previous Thread: How to insert data into database?
- Next Thread: Session.isNew() problem
| Thread Tools | Search this Thread |
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






