0

I visited Servlet not being mapped, java web.xml not being overridden in target folder and tried to implement.

My web.xml automatically created whenever Servlet added by using Neatbeans interface and resides in project_folder/src/main/webapp/WEB-INF/ and has follwing content like below (Default created by Netbeans)-

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>AdminPathController</servlet-name>
        <servlet-class>AdminPathController</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>AdminPathController</servlet-name>
        <url-pattern>/AdminPathController</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

But when i hit address localhost:8080/entry-dispatch/AdminPathController returns an error HTTP Status 404 - Not Found

Later i put some plugin code in pom.xml like below to map the web.xml file like below -

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-war-plugin</artifactId>
   <version>2.4</version>
   <configuration>
      <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
   </configuration>
 </plugin>
Veshraj Joshi
  • 3,544
  • 3
  • 27
  • 45
  • How do you deploy your application? – Aritz Apr 24 '18 at 06:15
  • @XtremeBiker When i hit simply `localhost:8080/entry-dispatch/` then welcome page rendered successfully. No deployment Descriptor required to do so.. – Veshraj Joshi Apr 24 '18 at 06:19
  • And how do you implement `AdminPathController`? – Aritz Apr 24 '18 at 06:21
  • I add AdminPathController by using netbeans interface, and to map the web.xml i write plugin code in pom.xml.... as given in manual .. @XtremeBiker I am going wrong with above code... – Veshraj Joshi Apr 24 '18 at 06:23
  • Well, you need actually a servlet.. Find a good tutorial on how to implement a servlet (there are dozens over the internet). – Aritz Apr 24 '18 at 06:31
  • What you mean AdminPathController is not a servlet ...? it's a actual servlet `public class AdminPathController extends HttpServlet {...}` – Veshraj Joshi Apr 24 '18 at 06:36
  • is there anyway to define actual servlet other than this @XtremeBiker – Veshraj Joshi Apr 24 '18 at 06:45
  • You can't expect people to know you've got a servlet if you don't provide the code in the question.. :-S – Aritz Apr 24 '18 at 08:07

0 Answers0