You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by jacky <ja...@gmail.com> on 2007/04/03 11:47:28 UTC

servlet url pattern problem!

in web.xml:
<servlet-mapping>
        <servlet-name>login</servlet-name>
        <url-pattern>/servlet/login</url-pattern>
</servlet-mapping>
in jsp:
 <FORM action="<%=request.getContextPath()%>/servlet/login" method="POST" >
There is an error when the jsp is submit (URL:
http://localhost:8080/test/servlet/login):

type Status report
message /test/servlet/
description The requested resource (/test/servlet/) is not available.

If i remove servlet/,the url http://localhost:8080/test/login can be
accessed correctly.
in web.xml:
<servlet-mapping>
        <servlet-name>login</servlet-name>
        <url-pattern>/login</url-pattern>
</servlet-mapping>
in jsp:
 <FORM action="<%=request.getContextPath()%>/login" method="POST" >

Your help is appreciated!
-- 
  Best Regards.
      jacky

Re: servlet url pattern problem!

Posted by jacky <ja...@gmail.com>.
It is amazing! Thanks, i will look into it to find out what is the problem.

On 4/5/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>
> 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 <ja...@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
>
>


-- 
  Best Regards.
      jacky

Re: servlet url pattern problem!

Posted by Rashmi Rubdi <ra...@gmail.com>.
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 <ja...@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


Re: servlet url pattern problem!

Posted by jacky <ja...@gmail.com>.
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



On 4/3/07, David Delbecq <de...@oma.be> wrote:
>
> En l'instant précis du 03/04/07 11:47, jacky s'exprimait en ces termes:
> > in web.xml:
> > <servlet-mapping>
> > <servlet-name>login</servlet-name>
> > <url-pattern>/servlet/login</url-pattern>
> > </servlet-mapping>
> > in jsp:
> > <FORM action="<%=request.getContextPath()%>/servlet/login"
> > method="POST" >
> > There is an error when the jsp is submit (URL:
> > http://localhost:8080/test/servlet/login):
> >
> > type Status report
> > message /test/servlet/
> > description The requested resource (/test/servlet/) is not available.
> You tried to post to <webapp>/servlet, not <webapp>/servlet/login
> according to your error message. Check you didn't forget a /login
> somewhere in your jsp.
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
  Best Regards.
      jacky

Re: servlet url pattern problem!

Posted by David Delbecq <de...@oma.be>.
En l'instant précis du 03/04/07 11:47, jacky s'exprimait en ces termes:
> in web.xml:
> <servlet-mapping>
> <servlet-name>login</servlet-name>
> <url-pattern>/servlet/login</url-pattern>
> </servlet-mapping>
> in jsp:
> <FORM action="<%=request.getContextPath()%>/servlet/login"
> method="POST" >
> There is an error when the jsp is submit (URL:
> http://localhost:8080/test/servlet/login):
>
> type Status report
> message /test/servlet/
> description The requested resource (/test/servlet/) is not available.
You tried to post to <webapp>/servlet, not <webapp>/servlet/login
according to your error message. Check you didn't forget a /login
somewhere in your jsp.

---------------------------------------------------------------------
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