Solved

How to run a simple JSP in Tomcat.

Posted on 2004-08-25
12
300 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now