• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I get a .jsp page in a subdirectory served as the first page?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat Version: 7.0.35

Given this directory structure under CATALINA_HOME/webapps/ on my local machine:

REAL_SIMPLE_TEST
* WebContent
**REAL_SIMPLE_TEST_HOME.jsp

**styles
***Stylesheet.css


* WEB_INF
** web.xml


How do I get REAL_SIMPLE_TEST_HOME.jsp served as the first page when in the browser I hit: http://localhost:8080/REAL_SIMPLE_TEST/ ? Placing

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

in the web.xml is not working.

(The reason I am asking this question: Some years ago I built a web application hosted by Webappcabaret using basically this structure. The people at Webappcabaret tweaked something or other and got this to work. Now I have to move my application out of Webappcabaret into a new host. But when I get all the files into a .war file and put it in the webapps directory of the Tomcat7 on my local machine, the homepage no longer gets served as the first page. Also, Tomcat no longer recognizes the style sheet placed in the subdirectory. I am trying to get these issues resolved on my local machine before placing the web application in a new host.)


 
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Clifford Wirt ,

Firstly you have to understand the directory structure of a web application and how it gets deployed as war on tomcat. The important thing to understand is that the WebContent folder is the root of your project hierarchy and all references made to subfolders inside webcontent are to be referenced from root. So if you REAL_SIMPLE_TEST_HOME.jsp is located directly inside the WebContent folder, then you have to put the following entry in your web.xml


Similarly for your styles folder, refer it to as /styles/Stylesheet.css

Do post back for any further queries
 
Clifford Wirt
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, this does not work:



I get an Apache Tomcat Status 404 error.

I should mention that RealSimpleTest is under the webapps directory. Tomcat seems to interpret the '/' as meaning 'webapps/RealSimpleTest'. But I need the first page served to be uner webapps/RealSimpleTest/WebContent instead.
 
Saif Asif
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try removing the forward slash from the path of the JSP . Its at the root of the project , so it should have worked . ( always works for me ) . Anyhow try to remove the "/" from the path and change it to "REAL_SIMPLE_TEST_HOME.jsp"
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect that you are depending on your IDE to deploy the web application. Depending on the IDE and plugins involved, it's most likely that "/WebContent" is actually something like the root of the WAR that the IDE assembles into. Thus, the true resource path within the webapp would be "/index.jsp".
 
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic