File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

response.sendRedirect help needed

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which URL is the browser trying to access - does it exist?
 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Mark Garland
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example is my application's name. On loading, it will display index.html
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • 0
  • Mark post as helpful
  • send pies
  • 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");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic