• 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 help needed

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

I was trying out a small example, I have a page called index.html which is a framed page and to the left frame I have several links with the first link pointing to index.jsp which will display in the right frame. Now in the right frame, i.e., in the index.jsp, I have a submit button and when I click submit button, it will go to a servlet and in that servlet I'm redirecting it to another jsp which is in the same location as this index.jsp. But when I tried this, it gives me a 404 error

Here is the code that I tried,


afterwhich I get a 404 error
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which URL is the browser trying to access - does it exist?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, the addchoice.jsp lies in the same place as the other html and jsp files. I'm using frames...would that be any problem?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, my question was which URL the browser was trying to access, not which JSP page you think it should be accessing. If you're getting a 404, that means there is a disconnect between the two.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I note that all of your links are relative - "index.jsp" etc.
Except the one you are redirecting to which is an absolute link "/addchoice.jsp".

I think this is what Ulf is trying to establish by asking what URL is being requested.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, when I press submit in the index.jsp, this is the url that I see,

http://localhost:8084/Example/

It should have taken me to http://localhost:8084/Example/addchoice.jsp instead....right?? So what went wrong?
[ June 20, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Example is my application's name. On loading, it will display index.html
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jothi Shankar Kumar Sankararaj:
Ok, when I press submit in the index.jsp, this is the url that I see,

http://localhost:8084/Example/



Since the page you're working with is in a frame, what you see in the URL line is not what the browser just requested for that one frame. Do a right-click on the 404 page, and let the browser tell you which URL it accessed for that particular frame.
 
Ranch Hand
Posts: 72
Scala Monad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the argument to sendRedirect() is a relative url with a leading '/', it is relative to servlet container root..
so you should specify your context root also in the URL..
your code should be

response.sendRedirect("/Example/addchoice.jsp");
 
reply
    Bookmark Topic Watch Topic
  • New Topic