Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Running JSP in tomcat  RSS feed

 
megha kanth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have installed tomcat and able to run the examples already present in that but suppose i make a folder called practice in webapps of tomcat directory and put my jsp files in that then i am not able to run the files. It gives me error --

type Status report

message /practice/test1.jsp

description The requested resource (/practice/test1.jsp) is not available.


Now when i copy the entire folder and keep it in the examples folder of the tomcat then i am able to run th jsp files.

What is the problem? Do I need any other thing as well for running JSP? What is the significance of WEB-INF folder? Is it the one which needs to be defined if i want to run jsp.

Pls explain.

Thanks
megha
 
Nitin Jawarkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friend,

You need to add the context path in server.xml file which is located in /tomcat5.x/conf/ means whatever you have create folder just add the name of that folder in context path, it look like this

<Context path="/Project" docBase="Project" debug="0"
reloadable="true" crossContext="true">

where Project is your folder name. It called creating Virtual Directory
Hope it will help you.
Thanx
 
megha kanth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitin,

thx for the prompt reply. After wch line do i need to add the context path?

megha
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi MeghaKanth,
What version of Tomcat are you using?
If you are using Tomcat 4 and above, you open the Tomcat console(Tomcat manager) and deploy your Web application folder.

You can already see few deployed folders like /examples.Thats why your application is working when u put the source files under 'examples'.

If your application is a 'war' file then browse to that location and create it. If its just a folder with some jsp's then Copy that Folder under
the Webapps.

Restart the tomcat .it should work..


Thanks,
Raj
 
Himanshu Bisht
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

what my view is that if you are putting ur application inside webapps directory then you don't need to set context root for it.It should run automatically from the address bar

Correct me if i am wrong.

himanshu
 
Nitin Jawarkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Megha,

If you got server.xml then there is a commented line
<!-- Tomcat Examples Context -->
you have to add your context path, there is already defined one, you have to just add your folder name instead existing.
Definatly it will work, good luck.
 
Nitin Jawarkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi megha,

Don't forgot to restart the tomcat server after any chages to server.xml file.

 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitin,
dont you think that handling xml manually is not a good idea.
why dont use the console,when its been provided for these purposes itself.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nitin Jawarkar:
You need to add the context path in server.xml file which is located in /tomcat5.x/conf/ means whatever you have create folder just add the name of that folder in context path, it look like this


No, that is false. You don't need to add a context entry to server.xml. In fact for Tomcat 5x and up, the documentation recommends NOT doing so.

All you need to do to create a webapp is:
Create a folder under TOMCAT_HOME/webapps.
In that folder create another folder called WEB-INF (case-sensitive).
That's it.

You should also add a web.xml file to the WEB-INF directory.
You can copy the one from TOMCAT_HOME/webapps/ROOT/WEB-INF and remove the servlet/jsp entries.


I've published some simple servlet/jsp examples that you can play with if you like.
http://simple.souther.us
All you need to do is download the war files to your webapps directory and they will run. They all have the proper directory structure.
 
megha kanth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx everyone..

It worked....
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!