Hello!
I am trying to follow this example
but I can't understand this part:
Imagine also that the servlet's context path is myServer/myApp/servlets. The servlet container would direct a request with URL myServer/myApp/createUser.do myServlet to myServlet, because the request URL matches the pattern *.do. Servlet myServlet can extract the requested operation's name from the request URL.
I can't understand the request, shouldn't it be myServer/myApp/myServlet/createUser.do? And how can one create such a request? Can I just put myServlet/createUser.do in the action of a form?
Thank you for your time.
Iulia
views:
60answers:
1
A:
No, you create a mapping to your servlet for myapp. The servlet name itself usually never shows in the request URL. So every request that goes to myapp will be redirected to your servlet if it matches. That means that your mapping
redirects every request with a .do to your servlet. Now the servlet has to deal with the request URL (e.g. render the view for createUser)
Daff
2009-07-31 11:12:47
Thank you for your reply. I've been playing around with it and I've got one question. I'm trying to make the login screen. By default the index.jsp opens:http://localhost:3818/MyApp. I've added this: ${pageContext.request.contextPath}/signin.do at the form's action and this <servlet-mapping> <servlet-name>Dispatcher</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> to web.xml. This will not work (makes a submit, gets through, values null). However, if the web-app is opened with http://localhost:3818/MyApp/signin.do it does work.
Iulia
2009-07-31 20:12:45
Iulia
2009-07-31 20:19:06
I don't really know what you want to do... in fact you don't even say what servlet implementation you are using. You mapping just sais that every call of <whatever>.do will be redirected to your servlet. So Just calling localhost:3818/MyApp simply doesn't redirect because it doesn't have a .do extension (localhost:3818/MyApp/index.do would work though.
Daff
2009-07-31 20:35:30