Solved

How to run a simple JSP in Tomcat.

Posted on 2004-08-25
12
308 Views
Last Modified: 2008-02-01
Hi Experts;

I have a simple jsp program that writes in a file. The problem is every time I try running the program Tomcat_5.0 gives an error like :

HTTP Status 404 - /1stweb/Sample.jsp
type Status report

message /1stweb/Sample.jsp

description The requested resource (/1stweb/Sample.jsp) is not available.
Apache Tomcat/5.0.27

I thought it will automatically compile and run it w/o any problem ? Other java webserver like Jetty and Blasix compiles and runs
the program w/o any problem. How can I solve this, thanks.



0
Comment
Question by:rajah_mohammed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 11898887
>description The requested resource (/1stweb/Sample.jsp) is not available.
Please give the full path.
Where in Tomcat did you put Sample.jsp ?
Can you see Tomcat's home page ?
Can you run the examples on that page ?         rrz
0
 

Author Comment

by:rajah_mohammed
ID: 11898955
> Where in Tomcat did you put Sample.jsp ?
in C:\Software\Tomcat_5.0\webapps\1stweb\Sample.jsp

> Can you see Tomcat's home page ?
Yes, because the server is running !.

> Can you run the examples on that page ?
Examples of Tomcat is running w/o any problems.
0
 

Author Comment

by:rajah_mohammed
ID: 11898974
I'm not using any IDE, do I need to create any other folder any xml file ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:rrz
ID: 11899199
>do I need to create any other folder any xml file ?    
I had to test again with Tomcat 5.
The minimum web application in Tomcat contains a WEB-INF folder. In that folder is a web.xml.  That file should at least contain the following for Servlet 2.4 .               rrz
-----------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
</web-app>
0
 
LVL 6

Assisted Solution

by:expertmb
expertmb earned 20 total points
ID: 11899480
create webapps\1stweb\WEB-INF as rrz written and have web.xml in tht folder.
restart the server.
0
 

Author Comment

by:rajah_mohammed
ID: 11899582
Hi Guys;

Thanks for the quick response : As you said above I've made a WEB-INF and placed it inside like :
C:\Software\Tomcat_5.0\webapps\1stweb\WEB-INF

I've also made a web.xml like what you guys are suggesting and placed it inside WEB-INF like :
C:\Software\Tomcat_5.0\webapps\1stweb\WEB-INF\web.xml

I tried running my simple program w/c writes in a file which is actually working fine w/ other
webservers like Jetty_5.0 and Blazix but in Tomcat as I followed your suggestion.

I encountered an error again, this time its :

HTTP Status 500

type Exception report
message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
      org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
      org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
      org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
      org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
      org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.

How can I solve this ? thanks . . .
Regards : Rajah
0
 
LVL 27

Expert Comment

by:rrz
ID: 11899598
>Perhaps JAVA_HOME does not point to the JDK    
Did you set JAVA_HOME  in your  autoexec.bat  ?
0
 

Author Comment

by:rajah_mohammed
ID: 11899652
No, How can I set it ???
0
 
LVL 27

Accepted Solution

by:
rrz earned 20 total points
ID: 11902440
Did you install the JDK on your machine ?
If so, then add this line to your autoexec.bat  file  
SET JAVA_HOME=fullPathToYourJDK
and restart Tomcat.    rrz
0
 

Author Comment

by:rajah_mohammed
ID: 11907759
I just actually did it in command prompt before running the startup.bat thanks a lot.
0
 

Author Comment

by:rajah_mohammed
ID: 11907768
Do you happen to know the default admin name and password of tomcat ?
0
 
LVL 27

Expert Comment

by:rrz
ID: 11908936
You should look in
C:\Software\Tomcat_5.0\tomcat-users.xml                         rrz
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of things can happen during a presentation, worst of which is “death by PowerPoint.” Here are a few mistakes to avoid to make your slides clean.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question