• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

URL Redirection

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic