Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

response.sendRedirect issue

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a servlet which has a some logic after which it does a send redirect.

response.sendRedirect("url") ;
Now this works fine on my local setup and the url page is displayed properly. However, when I try it on a different setup, the url shows a servlet name and the page is blank.

What might be the reason for this ? . There is a return statement after the redirect.

Is it some problem with the redirect ?

thanks,
Aditya
 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adi,
Can you post the url please. whether it is relative url or absolute url? which you have used?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to check the url and a return statement after a redirect is not really helpful.
Are you sure there is no exception?
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The URL is relative. Its something like . response.sendRedirect("confirmation.jsp")

I can't see the logs for exception because its on some other machine. But I'm puzzled because its working properly on my local setup.

Also, just the redirect is not happening and all the backend updations are happening.

thanks,
Aditya
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adi Kulkarni wrote:The URL is relative. Its something like . response.sendRedirect("confirmation.jsp")


Page-relative URLs are very fragile. The first thing I'd do is to change this to a server-relative URL that begins with the context path.
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Bear,

I noticed that our url has some blank spaces.

Example


response.sendRedirect("confirmation.jsp?a=<variable1>&b=<variable2> &c=<variable3>")


Will this blank page cause issues. Also from the log trace that we have got, the sendRedirect is getting called and after that there is some user defined exception.

Thanks,
Aditya
 
Your mind is under my control .... your will is now mine .... read this tiny ad
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic