Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a little more explanation on how to use urlmapper

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic