How to remove the project name in the Java Servlet Url

1

I have a question and I have already searched the entire internet and I did not find, how the hell did I get the name of the url project in java? ex:

http://localhost:8084/MeuProjeto/login

for

http://localhost:8084/login

Thank you!

obs: jdk8

    
asked by anonymous 20.11.2017 / 22:42

1 answer

1

I do not know if you are using a framework like Spring, but if you are using pure Servlet you need to configure the web.xml file for the project:

Something like this:

<servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>pacote.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
    // Classe servlet que responde por essa URL
    <servlet-name>LoginServlet</servlet-name> 
    // URL que deseja mapear
    <url-pattern>/login</url-pattern> 
</servlet-mapping>

To create the file in NetBeans:

1. On the top menu, click File, choose New File. 2. On the screen that opens, select Web Category, then select Standard Deployment Descriptor. 3. Click Next. 4. Click Finish. The web.xml file will be created in the web directory / WEB-INF /.

    
21.11.2017 / 01:11