| Author |
How does the url "webappname/servlet/..." work well?
|
Simeon Shi
Ranch Hand
Joined: Dec 09, 2001
Posts: 35
|
|
First, the following is the physical path of my web application. ... ---BankAccount └ WEB-INF │ └classes │ │ └webapplication │ │ └AccountServlet.class │ │ └LoginServlet.class │ └web.xml └ login.html I try to access the URL "http://127.0.0.1:8080/BankAccount/login.html",which the login.html post a request to the servlet LoginServlet which is in the package webapplication.Then the LoginServlet will redirect to the AccountServlet if the login is ok.I use the req.getRequestDispatcher("/AccountServlet").forward(req, res) to get the user's account info.However, the question arised here.In the book, it use the req.getRequestDispatcher("/servlet/AccountServlet").forward(req, res) and also will sucess.It is strange about the /servlet/... What does the path means?I don't have such package or directory. I tried some other web application then and I found that the path "/servlet/..." all work well.Can anyone help me? [ September 12, 2002: Message edited by: simeon shi ]
|
 |
Mark Howard
Ranch Hand
Joined: Feb 14, 2001
Posts: 285
|
|
Hi Simeon Good question. Confuses me as well. I think the /servlet is a default directory in the Servlet deployment structure. See this link in the SCWCD thread, where similar concerns are raised.
|
 |
tonyqu
Greenhorn
Joined: Sep 02, 2002
Posts: 2
|
|
You should view web.xml file to see servlet mapping configration. For example: <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>/Servlet/ActionServlet</url-pattern> </servlet-mapping> Then you can visit ActionServlet.class through the url "http://localhost/Servlet/ActionServlet" Hope it can help you.
|
 |
Simeon Shi
Ranch Hand
Joined: Dec 09, 2001
Posts: 35
|
|
|
Actually,I made the web.xml by myself in which I didn't assign the <servlet-mapping> tag.
|
 |
 |
|
|
subject: How does the url "webappname/servlet/..." work well?
|
|
|