3

index.jsp

 <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%="This is First App" %> 
    </body>
    </html>

web.xml file :

 <display-name>JSPAPP</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

when i run the app http://localhost:8080/JSPAPP/index.jsp using its work fine But i have change this URL to http://localhost:8080/MyFirstApp/index.jsp i.e i have to change JSPAPP to MyFirstApp how i will change please tell me .

Research Development
  • 884
  • 1
  • 19
  • 39

1 Answers1

1

1) if you are using eclipse to run the application then change the context root from the project "Properties --> Web Project Settings --> Context Root".

2) if you are deploying your app to a server (say tomcat)rename your war file to the context root you desire.

KDP
  • 1,481
  • 7
  • 13
  • I have tried to follow first one but i am unable to run it – Research Development Jun 29 '15 at 09:05
  • I have change Contextroot to MyFirstApp but still .http://localhost:8080/JSPAPP/index.jsp its running like this while http://localhost:8080/MyFirstApp /index.jsp i want his – Research Development Jun 29 '15 at 09:07
  • you don't need any changes in servlet.After changing the context root in project properties you have to remove your web application from Tomcat (using Add and Remove... on the context menu of the server), redeploy, then re-add your application and redeploy refer this link http://stackoverflow.com/questions/2437465/java-how-to-change-context-root-of-a-dynamic-web-project-in-eclipse – KDP Jun 29 '15 at 09:14