Here is the Oracle site from where I tried to learn JSP http://192.9.162.55/products/jsp/html/jspbasics.fm2.html

But after following all th instructions and creating folders as per site I got a big error-
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: /hellouser.jsp (line: 3, column: 0) The value for the useBean class attribute hello.NameHandler is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1234)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Generator.generate(Generator.java:3490)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


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


--------------------------------------------------------------------------------

Apache Tomcat/7.0.21

Why this error is coming. Can any one help me.. Where I have made mistake.

Thanx for guidance

JSP is not able to find NameHandler class. Can you post your project structure and how you compiled this project?

First of all Thank you for considering my issue, I hope you visited the ORACLE site I mentioned -
My project structure is as follow-
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\hellouser\
background.gif
duke.jpeg
index.html
hellouser.jsp
response.jsp.

C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\hellouser\WEB-INF\jsp\beans\hello\
NameHandler.java
NameHandler.class

I complied the NameHandler.java file once with servlet-api.jar and once with jsp-api.jar but both the test was failed. I also try to change the project structure like this but failed -

C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\hellouser\WEB-INF\classes\hello\
NameHandler.java
NameHandler.class

I just copied the same code from the site I mention in previous post

Regards

Your folder structure is wrong and missing web.xml, should be as follow:

  • TOMCAT_DIR/webapps/hellouser
    • background.gif
    • duke.jpeg
    • index.html
    • hellouser.jsp
    • response.jsp
    • WEB-INF
      • web.xml
      • classes
        • hello
          • NameHandler.java

OK I changed the structure
But nothing mentioned about web.xml in oracle site. Even if I include this file what to write in this file?

Sorry, I did not read whole tutorial. Just search for simple tomcat WEB-INF web.xml example. Also use this compile command example. Once I get to work I will try to upload example of whole exercise

OK, here we go example as promised see post attachment. Just download and extract in your tomcat webapps directory. Compile with following command for Unix based OS (correct folder names and location as necessary)

javac -cp /home/peter/tomcat-7.0.21/lib/servlet-api.jar:classes:. /home/peter/tomcat-7.0.21/webapps/hellouser/WEB-INF/classes/hello/NameHandler.java

or Windows should be something like (not 100% sure as I'm on Unix for last few years, but can be easily later corrected if you post any errors on compile)

javac -cp C:\tomcat-7.0.21\lib\servlet-api.jar;classes:. C:\tomcat-7.0.21\webapps\hellouser\WEB-IN\classes\hello\NameHandler.java

This will create NameHandler.class on same level as NameHandler.java

Advise: Abandon that tutorial as it is very old and it will not teach you right things, rather get your self one of the books recommended in this post

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.