tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashmi Rubdi" <rashmi....@gmail.com>
Subject Re: servlet url pattern problem!
Date Thu, 05 Apr 2007 05:31:52 GMT
If you compile the Servlet class and Re-start Tomcat after defining
the mapping in web.xml it should work.

I tried the following and it works:

---------------------------------------------------------------------
web.xml
---------------------------------------------------------------------
    <servlet>
        <servlet-name>login</servlet-name>
        <servlet-class>test66.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>login</servlet-name>
        <url-pattern>/servlet/login</url-pattern>
    </servlet-mapping>

----------------------------------------------------------------------
LoginServlet  ---- compiled
----------------------------------------------------------------------
package test66;

import javax.servlet.*;

public class LoginServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse
response){
        doGet(request,response);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response){
        System.out.println(" Inside Login Servlet");
    }
}

------------------------------------------------------------------------------------
JSP
------------------------------------------------------------------------------------
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head><title></title></head>
  <body>
  <FORM action="<%=request.getContextPath()%>/servlet/login" method="POST" >
      <input type="text" name="text" value="hellooooo "/>
      <input type="submit" name="submit" value="submit" />
  </FORM>
  </body>
</html>

-Rashmi

On 4/5/07, jacky <jackychenp@gmail.com> wrote:
> It is <webapp>/servlet/login indeed. In fact, my jsp structure is as
> following:
> in index.jsp:
>   <jsp:include page="/jsp/top.jsp"/>
>
> in top.jsp:
> <FORM action="<%=request.getContextPath()%>/servlet/login" method="POST"
> onsubmit="return loginCheck(this);">
> ..
> </FORM>
> //here, the form will be submit
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message