Solved

How to run a simple JSP in Tomcat.

Posted on 2004-08-25
12
301 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xjc and jaxb 2 90
maven project in eclipse 11 57
excpetion with multiple catch 11 113
how to hide hide popup page refresh second time? 10 111
Fine Tune your automatic Updates for Ubuntu / Debian
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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