wood burning stoves 2.0*
The moose likes Servlets and the fly likes how to map url in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

how to map url in java

Nuha Iqbal
Greenhorn

Joined: Jul 24, 2012
Posts: 2
Hi,

I am beginner in Java, I had a problem in mapping the url with action attribute.

for example i have this web.xml

<servlet-map>
<servlet-name>example</servlet-name>
<url-pattern>pack/*</url-pattern>
</servlet-map>

then how can i call this servlet from jsp?
what to write in action?

<form action="??" method="get" >
....
</form>
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 194

this "web.xml" is not your servlet...
web.xml passes the clients request to servlet hiddenly...
so, that the client get no idea where your servlet is placed..

for clearification suppose..

<form method="post" action="foo.do">
.
.
.
</form>


in web.xml
<servlet-mapping>
<url-pattern>foo.do</url-pattern>
<servlet-name>foo file<servlet-name> //this is any name by your choice so, that your xml file knows this
</servlet mapping>

<servlet>
<servlet-name>foo file</servlet-name>
<servlet-class>com.example.foo<servlet-class> // this is the actual path of your servlet in com.example package
</servlet>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

This was discussed in this topic just yesterday. Please SearchFirst.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: how to map url in java
 
Similar Threads
Servlet Mapping
servlet doubt
how to connect Jsp to servlet to process parameters
Call servlet from very first JSP
Servlet and XML result HTTP 404