java ee - Change application context from inside a WAR inside EAR -


Is there a chance to shorten the URL to access my servlet? The current deployed URL is server: port / webpace / meservelet . I want to shorten it to server: port / myservlet

: The servlet is located inside a WAR archive that is inside an EAR archive.

Web WebApp.war / WEB-INF

  & lt; Display-name & gt; Webpad & lt; / Display-name & gt; & Lt; Servlet & gt; & Lt; Description & gt; & Lt; / Description & gt; & Lt; Display-name & gt; MyServlet & lt; / Display-name & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Com.company.MyServlet & lt; / Servlet category & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Myservlet & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;  

Service code here:

  @WebServlet ("/ *") Public class MyServlet implements HttpServlet Servlet {public MyServlet () {super () ; } Secure zero code (HTTPPR250 requests request, HTTPSvette response response) servlet upption, IOException {// some magic here}}  

PS: I need to work on both jabos and webserver .

Edit: My apologies, I forgot to tell that I can not change the context using application.xml .

You can access the App Reference Row from / WebApp to / , not servlet mapping. The best approach is to define it in the application.xml file:

  & lt; Application & gt; & Lt; Display-name & gt; MyApplication & lt; / Display-name & gt; & Lt; Module & gt; & Lt; Web & gt; & Lt; Web uri & gt; WebApp.war & lt; / Web uri & gt; & Lt; Context root & gt; / & Lt; / Reference root & gt; & Lt; / Web & gt; & Lt; / Module & gt; & Lt; / Application & gt;  

UPDATE If you do not have application.xml , you need ownership details.
Djibes - jboss-web.xml View

  & lt; Jboss-web & gt; & Lt; Context root & gt; / & Lt; / Reference root & gt; & Lt; / Jboss-web & gt;  

Websphere - ibm-web-ext.xml

   & Lt; / Web ext & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -