Hi,
I have a
jsp file with one text field and two
servlets. when i click submit button on the jsp file it goes to first servlet which will forward the request to second servlet.
my doubt is as below.
after submitting the jsp page in my first servlet when i call
req.getRequestURL() and req.getQueryString() it displays correct information
but when i forward the control to second servlet from first servlet and when print the value of req.getRequestURL() and req.getQueryString() it displays same information that was displyed for first servlet.
1)my doubt is for first servlet if it displays
http://localhost/scwcd/test as the output of req.getRequestURL() it should display
http://localhost/scwcd/processparam for second servlet because in my second servlet i am getting the req.getRequestDispatcher("processParam"); and forwarding so now the container will understand that it should build the URL some thing like
http://localhost/scwcd/processparam this and display the servlet. As per this it should display
http://localhost/scwcd/processparam as out put for
req.getRequestURL() but it displays the
http://localhost/scwcd/test as the request url which was built by container when jsp called my first servlet
test how can i get
http://localhost/scwcd/processparam as the out put for requesturl methode in my second servlet?
2)in chapter 5 Q12 of HFSJ it is said that we can access the original query
string when the request gets forwarded to other servlet and for this we should use req.getAttribute("Javax.servlet.forward.query_String"); and we cant use req.getQueryString() to get original Query String.
But when i say req.getQueryString() i am getting same QueryString as that of in first servlet and when i say req.getAttribute("Javax.servlet.forward.query_String"); it displays null what is actually happening here am i making any mistakes.
3)and at last in my web.xml the mapping i have given is as <url-pattern>/test/*</url-pattern> when the url is
http://localhost:8080/test it displays corect out put but when i make the request using this url
http://localhost:8080/test/1/2 it throws internal server error. but after /test/ we have "*" that means it should display servlet test for /test/,/test/1 or /test/1/2/3 with out any problem am i correct but i am getting errors. is my understanding wrong ?
Thanks
[ April 06, 2008: Message edited by: raja ram ]