• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL Redirection

 
Vrinda
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
I have the foolowing problem:
I have developed an applet that communicates with a servlet. The applet
sends some objects to the servlet. After doing some processing I want to
redirect to some other site from within my servlet.
I tried the following methods.
1. HttpResponse.sendRedirect(URL);
2. construct the printWriter
PrintWriter out= HttpResponse.getWriter();
and then construct an HTML response as
out.println("<html><head>....<body> ...</html>");
Unfortunately, none of these methods work . I am not getting any compilation
errors. also note that the above two methods work if the user interface is a form and fails
if the front end is an applet.
Please suggest an alternative.
Thanks in Advance
Vrinda
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this problem before.
In my experience, HttpResponse.sendRedirect(URL) won't work after the servlet write anything to the browser (I don't know why). What I did at last was using JavaScript to redirect the browser (let it delay 1~2s).
 
sean zang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What servlet Container(java Based Web server) Do you use?
If you use Jakarta -tomcat, the response.sendRedirect(URL) works
prety well! The problem is that you can not see out.println("somthing") if you response.sendRedirect(URl) statelmet follows the out.prinltln() because redreicted URL imediately occupy the browser! I use alots sendRedirect in my
project. it works fine. try to use response forward method !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic