-1

I have created dynamic web project in eclipse and added index.jsp file, obviously thats my welcome page.I have added it in web.xml,I am using angular js for front-end interface management.

here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="false" version="3.0">
<welcome-file-list>

    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
    <servlet>
    <description></description>
    <display-name>ValidateLogin</display-name>
    <servlet-name>ValidateLogin</servlet-name>
    <servlet-class>ValidateLogin</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ValidateLogin</servlet-name>
    <url-pattern>/ValidateLogin</url-pattern>
  </servlet-mapping>

</web-app>

now what my issue is When I run the project it is showing loading and not opening any content. but if I added the project url+index.jsp in browser address bar then the page loads successfully. I am using route provider in angular js script and that is as follows

app.js

var myApp = angular.module('myApp', [
    'ngRoute',
    'appController'
    ]);

myApp.config(['$routeProvider',function ($routeProvider) {

    $routeProvider.
    when('/home', {
        templateUrl: 'views/login.jsp',
        controller: 'LoginController'
    }).
    when('/main', {
        templateUrl: 'views/Home.jsp',
        controller: 'MainController'
    }).
    otherwise({ redirectTo: '/home' });

}]);

here is my dir structure

enter image description here

what is the issue ? can anyone answer ?

droidev
  • 7,352
  • 11
  • 62
  • 94

3 Answers3

0
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Add.jsp extension in index

Make sure your index.jsp is outside WEB-INF folder

For accessing the jsp the correct url will

http://localhost:8080/ProjectName/index.jsp

Change the port no as per your server. You need to provide the project url for accessing the jsp. Say you have 4 projects deployed on your server each having index.jsp. How will the container figure out which index.jsp to run if you don't provide the project url.

underdog
  • 4,447
  • 9
  • 44
  • 89
  • you wrote in the question when you add the project url jsp loads fine. – underdog Apr 30 '15 at 11:13
  • Yes it is.. I have edited the web.xml as you mentioned.but its not loads the welcome page.. – droidev Apr 30 '15 at 11:28
  • Re-read your question, what do you mean by jsp loads fine. And now you say does not load the welcome page – underdog Apr 30 '15 at 11:48
  • I can open the welcome page if i typed its absolute path like http://localhost:8080/Application/index.jsp .. But its not loading when i run the project or typed as localhost:8080/application/ – droidev Apr 30 '15 at 11:50
  • This issue has happened with me; some solutions; clear server cache restart your server; delete web.xml put another one; create a new app & copy the code – underdog Apr 30 '15 at 11:53
  • Let me check that.. The server takes lot of times to reload the changes – droidev Apr 30 '15 at 11:55
0

You have mentioned welcome file without any file extension

     <welcome-file>index</welcome-file>

just add valid welcome page with file extension, if may be your file is index.jsp

   <welcome-file>index.jsp</welcome-file>

and your $routeProvider configuration doesn't affect your welcome page loading you mentioned in the web.xml. route provider only affect after your angular js loaded...

Babu Pasungily
  • 315
  • 3
  • 13
0
  1. Make sure the welcome-file property is mentioned like this: index.jsp

  2. Make sure the index.jsp is present parallel to WEB-INF.

Hope this works.

Ravi Ranjan
  • 740
  • 2
  • 10
  • 31