rampatel
rampatel

Reputation: 541

Doubts in Servlet works

We have an existing application where servlets has been loaded with URL (mentioned below) and they had not defined in web.xml.

domain:9080/Smart/servlet/com.wm.FacXmlServlet

Here FacXmlServlet class placed inside com.wm package.

Is it possible to do as per servlet rule where we defining that in web.xml servlet tag ?

Upvotes: 0

Views: 84

Answers (1)

Akash Thakare
Akash Thakare

Reputation: 23012

You can specify the package in web.xml,which means com.package.Test Servlet class has been mapped to /go/test url or you can just annotate your class @WebServlet("/path/MyServlet") and that's it.

<servlet>
    <servlet-name>servlet1</servlet-name>
    <servlet-class>com.package.Test</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>servlet1</servlet-name>
    <url-pattern>/go/test</url-pattern>
</servlet-mapping>

Upvotes: 1

Related Questions