Solved

How to run a simple JSP in Tomcat.

Posted on 2004-08-25
12
304 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Apache server configuration 7 87
library class in java 1 93
maven disable workspace resolution 1 19
how to debug htl and js pages 8 38
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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