Solved

How to run a simple JSP in Tomcat.

Posted on 2004-08-25
12
303 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display current date,month,and year to JTextField 3 53
reflection example 3 101
struts exact match support 3 56
Use tracing facilities in your browser steps 2 117
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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