File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Need a little more explanation on how to use urlmapper Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Need a little more explanation on how to use urlmapper" Watch "Need a little more explanation on how to use urlmapper" New topic
Author

Need a little more explanation on how to use urlmapper

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
I am having a problem calling a servlet : createANewqueryServlet

I have followed the example in the link
:http://faq.javaranch.com/view?InvokerServlet
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>your.package.name.HelloWorld</servlet-class>
</servlet>.

<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

I have assumed that hello is : http://localhost:8080/hello.



What is happening is I have a JSP page that calls createANewqueryServlet, with the form call:

<form action="uaMMtest/com.gfi.monitormaintenance.createANewqueryServlet" method=post>

Now this call works, the servlet verifies the data and either calls another page or the calling JSP page so that the user can enter the correct data.

If I go back to the first JSP Page and press submit I get the following error: The requested resource (/uaMMtest/uaMMtest/uaMMtest/com.gfi.monitormaintenance.createANewqueryServlet) is not available.



In my own web.xml I have

<servlet>
<servlet-name>createANewqueryServlet</servlet-name>
<servlet-class>com.gfi.monitormaintenance.createANewqueryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>createANewqueryServlet</servlet-name>
<url-pattern>
/uaMMtest/com.gfi.monitormaintenance.createANewqueryServlet
</url-pattern>
</servlet-mapping>

if I just have
<url-pattern>
/uaMMtest
</url-pattern>

It fails on the first call.

What else do I need to set up so that jspPageA can invoke createANewqueryServlet which can forward to jspPageA which can again invoke createANewqueryServlet.

Thanks for any help

Tony
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
Solved the problem and finally understand how it works.

test was not the name of the application, it is the name of the servlet.

So in my web.xml I have the following:
<servlet>
<servlet-name>createANewquery</servlet-name>
<servlet-class>com.gfi.monitormaintenance.createANewqueryServlet</servlet-class>
</servlet>
<servlet>
<servlet-mapping>
<servlet-name>createANewquery</servlet-name>
<url-pattern>/createANewquery</url-pattern>
</servlet-mapping>


and in my JSP page I invoke the servlet with the following line of code:

<form action="createANewquery" method=post> which calls the servlet by name.

Hope this helps other confused newbies.

Tony
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need a little more explanation on how to use urlmapper