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 ]
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.
Joined: Dec 09, 2001
Actually,I made the web.xml by myself in which I didn't assign the <servlet-mapping> tag.