• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:forward or response.sendRedirect do not work  RSS feed

 
Katia Platonov
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,
I have a page that has a conditional include JSP.
In turn that JSP has to either display general data if many records are returned or jump to details page if only 1 record is returned.
Counting records no problem. But I'm having difficulty redirecting. Neither forward nor redirect work at all.
Here is my code (with some pseudo code):

I tried doing something like this:
String url1 = "userdetails.jsp?lookup=";
String url2= rs.getString( "user_id" );
String url=url1+url2;
<jsp:forward page="<%=url%>" />
Also tried:
response.sendRedirect("http://userdetails.jsp?lookup=myvariable");
Please please help me.
Thank you.
Katia.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Katia, in the future it's a good idea to be a little bit more explicit about what "doesn't work" means.
But in this case I'm guessing that your problem is that you are sending data to the output stream before you are attempting to perform the redirect/forward. If you are going to redirect or forward you must do so prior to comitting output to the response.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!