Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

sample jsp via Tomcal

I wonder if someone could help me with the following questions.

This is a part of path for your consideration:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\begjsp-ch04\classes

1. I have installed Tomcat and not sure how to start it.

2. When I reboot my computer, I get “Access is denied, Unable to open service 'Tomcat7' “
Is this my laptop firewall preventing it from running? What can I do to run Tomcat without turning off my security software off?

3. I have made a jsp page coppied to:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\begjsp-ch04\classes\carPage2.jsp

4. There is also a Car class prepared not sure where it goes.

Any kind of help is appreciated.

Thank you,
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

It looks as if you're following a book or tutorial -- which one?

Some answers:
>>C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\begjsp-ch04\classes

That path should have ROOT as part of it.  So you should create a subdirectory under webapps, like this:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\

Jsp pages -- things called xxx.jsp -- can be put in the ROOT directory

Under ROOT you need a WEB-INF directory
[tomcat home]\webapps\ROOT\WEB-INF
under WEB-INF goes the classes directory
[tomcat home]\webapps\ROOT\WEB-INF\classes
Also in WEB-INF goes the web.xml file for your webapp.  If you're working from a book or tutorial, there should be a sample web.xml file, something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
         http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
</web-app>

This is a nice tutorial on setting up Tomcat 7:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/
You don't have to use Eclipse, which is a Java development tool, but you're welcome to try it if you want.  The coreservlets.com site also gives directions for setup without Eclipse, which you could follow for your work.

Check if Tomcat is started and running correctly.  This is a good set of steps for that:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/test-server.html

>>2.  I get “Access is denied, Unable to open service 'Tomcat7' “
Yes, the normal install from Tomcat is to run as a service.  However, the user which tries to run it does not have sufficient privileges.  There are various solutions, see below for some options:
http://superuser.com/questions/284657/tomcat7-service-cannot-start-on-windows-7-even-when-it-is-set-to-log-in-as-admin

>>3.  jsp page
As mentioned above, a .jsp page should go someplace like this:
[tomcat home]\webapps\ROOT\xxx.jsp

>>4. Car class
I'm assuming that you mean a .jar class.  It's best to put it in the lib directory for your webapp:
[tomcat home]\webapps\ROOT\WEB-INF\lib
>>>>>1. I have installed Tomcat and not sure how to start it.

go to  command promt C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin> java    -jar bootsriploader.jar


this will start your application . or you can use startup.bat in C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin folder
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Presumably your problem is fixed.  It's odd that you did not give the points to the first correct answer -- did you know that you can give it to the first person who answers, or to 2 people if you feel a second person contributed something different?  Just FYI for the next time you're interested in help from experts.