• Post Reply Bookmark Topic Watch Topic
  • New Topic

LWS + servlet + jsp = "Page not found"  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey folks,
I'm new to this Java thing, so I'll try as best as I can to make my question make sense.
I'm using LiteWebServer to test a pre-production password/database/jsp thingy.
Here's where I'm at right now:
HTML page with a form that inputs a password and username and forwards it to the servlet.
ALL I need the servlet to do at this point is pass the info back to a JSP and all the JSP is going to do is write a new HTML page with the username and password. Once I can get this to work we'll get back to the database connection, etc.
However, after I hit "submit" and the stuff heads over to the servlet, I get "page not found" in the browser window. My mentor is telling me to look at classpaths and LWS properties files, and I've changed each of them twelve ways and still can't get this thing to work.
In the LWS window I have it print out the path that should be displayed, and it seems okay.
String rp = getServletContext().getRealPath(urlToForwardTo);
System.out.println("Forwarding to: " + rp);
RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(urlToForwardTo);
In my LWS window it is correctly saying:
"Forwarding to: C:\LWS-2.2.1\html\emstest\hello.jsp"
But it doesn't get there.
Thanks for any and all help, and with such a bizarre, generalized question I will understand perfectly if nobody has any ideas. If only I could get the guy in the desk behind me to just TELL me instead of trying to get me to "learn"...
[This message has been edited by GriffeyMac (edited June 21, 2001).]
Frank Carver
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are misunderstanding the way request dispatching works. You don't need to do the "getRealPath", because the request dispatcher automatically assumes that the name you give it is available from the server, so you give it a relative url, as you would in a web page link.

If hello.jsp is in the same directory as the calling one, then this should just work. If you are calling it from an automatically located servlet (such as http://blah.com/servlet/WhateverServlet) then you will need to use something like "../hello.jsp" as the url.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!