File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward/redirect in jsp

 
michael yue
Ranch Hand
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to redirect/forward from jsp file to another jsp file but it ended up in error. Using request dispatcher my code are
RequestDispatcher listpg=getServletContext().getRequestDispatcher("/updlist.jsp");
listpg.forward(req,res);
I also tried
res.sendRedirect("updlist.jsp");
but still cannot.
I put the execution code in an if block. Can someone point out the reason. thanks.

<%
if (rowsaffect >=1)
{
%>
<h1>Modify Successful</h1>
<br>
<script type="text/javascript">
popmesg()
</script>
<%
listpg.forward(req,res);
}
else
{
%>
<h1>Unsuccessful</h1>
<%
}
 
Nadeem Ahmad
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use
response.sendRedirect(URL);
Hope this will work
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hero,
Why are u creating trouble for yourself. Totally remove that RequestDispatcher part and use <jsp:forward page="xyz" /> in your if loop.
It will work 100%. If it doesnt means it hasnt entered ur if statement.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you not think that it would be useful to actually show the error that you are getting?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic