Will and this is doing, What is the connection between them? ? ?

Category: Java EE
 
e7ffcom
2013-08-20 01:59:12

Sponsored Links
<servlet>
<servlet-name> login </ servlet-name>
<servlet-class> cn.mldn.lxh.note.servlet.LoginServlet </ servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> login </ servlet-name>
<url- pattern> / ksm01/WebRoot/Login </ url-pattern>
</ servlet-mapping>

Will <url-pattern> </ url-pattern> ; and this <servlet-class> </ servlet-class> is doing, What is the connection between them? ? ?

Sponsored Links

UN20091124
2013-08-20 02:04:50
url-pattern is your url to access the path, such as
http://localhost/ksm01/WebRoot/Login

and servlet-class ; that visit this url, call the servlet
liudadan120
2013-08-20 02:21:57
url-pattern mode is a way to access servlet and servlet-class
it both through the servlet-name for the media echo each other
three are built around a central (servlet) turn
shenyt07
2013-08-20 02:38:22
ask about is this class - cn.mldn.lxh.note.servlet.LoginServlet is not because of the in x: \ ksm01 \ WebRoot \ WEB-INF \ classes \ cn \ mldn \ lxh \ note \ servlet directory?
shenyang19840226
2013-08-20 02:52:32
correct,
subdirectories and package the same
linkenpary003
2013-08-20 02:55:12
Yes, it compiled. class file is placed in that directory
chengwen294645080
2013-08-20 03:03:17
Oh, right The ~
e_elgar
2013-08-20 03:18:13
There is my server tomcat is, after startup visit this http://localhost:8080/ex/ksm01/WebRoot/Login 404 error may be what causes it?
server.xml has been added <Context path="/ex" docBase="D:\example" />
LoginServlet class file is also appropriate folder below
m652500
2013-08-20 03:22:33
Your docBase clearly in
x: \ ksm01 \ WebRoot
how he is a d: \ example of? ? ?

mW_lyFe
2013-08-20 03:38:57
sorry ha, I re-do it with myeclipse into d: \ example \ ksm01 \ WebRoot
wuyeqihang110
2013-08-20 03:54:23
LoginServlet.java content is : (is a shining example for the others)
package cn.mldn.lxh.note.servlet;

import java.io. *;
import javax.servlet. *;
import javax.servlet.http. *;
import cn.mldn.lxh.note.vo. *;
import cn.mldn.lxh.note.factory. *;

public class LoginServlet extends HttpServlet
{
public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
this.doPost (request, response);
}
public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
String path = "login.jsp";
/ / 1, the received parameters passed
String id = request.getParameter ("id");
String password = request.getParameter ("password") ;;
/ / 2, the content of the request is assigned to VO class
Person person = new Person ();
person.setId (id) ;;
person.setPassword (password);

try
{
/ / for database authentication
if (DAOFactory.getPersonDAOInstance ( ). login (person))
{
/ / If true, it means that the user ID and password legitimate
/ / Set the user name to session scope among
request.getSession (). setAttribute ("uname", person.getName ());
/ / modify the jump path
path = "login_success.jsp" ;
}
else
{
/ / login failed
/ / set the error message
request.setAttribute ("err" ;, "incorrect user ID and password!!!");
}
}
catch (Exception e)
{}
/ / to jump
request.getRequestDispatcher (path). forward (request, response);
}
};
wenj520
2013-08-20 04:07:50
then your configuration should be
<Context path="/ex" docBase="d:\example\ksm01\WebRoot" />
jgzhengx5
2013-08-20 04:21:57
Thank you very much boss upstairs
When configured this time: <Context path="/ex" docBase="d:\example\ksm01\WebRoot" />
<url -pattern> / Login </ url-pattern> configuration is able to access
Why not do it this time? I still have not understood
<Context path="/ex" docBase="d:\example" />
<url-pattern> / ksm01 / WebRoot / Login </ url-pattern>
configure access addresses these two the same?
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.