Hi ,everybody i am trying to use beans in jsp.....but i am stucked in first step...
i have copied code from somewhere ......here beans uses a package .Beans is compiled successfully and called bean by this tag in jsp

<jsp:useBean id="MyConnectionBean" scope="session" class="UserPack.ConnectionBean"/>

Here UserPack is package of bean
now i placed this jsp and a folder Userpack containig ConnectionBean.class in Root of Tomcat 6.0
Now when running this jsp file from browser it shows some errors......
First time it shows these errors
----------------------------------------------------
org.apache.jasper.JasperException: org.apache.jasper.JasperException: /MainPage.jsp(9,0) The value for the useBean class attribute UserPack.ConnectionBean is invalid org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.apache.jasper.JasperException: /MainPage.jsp(9,0) The value for the useBean class attribute UserPack.ConnectionBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:406)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:147)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3397)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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

On refreshing the page it shows
----------------------------------------------------
org.apache.jasper.JasperException: org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:160)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:148)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.MainPage_jsp
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:148)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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

@now i placed this jsp and a folder Userpack containig ConnectionBean.class in Root of Tomcat 6.0

Wrong placement. Web project structure under Tomcat is as follows
PATH_TO_TOMCAT_FOLDER/webapps/YOUR_PROJECT_NAME/

  • *.html, *.jsp
  • can have folder img (for images) and css (for cascading style sheets)
  • WEB-INF
    • web.xml
    • lib - for all additional JAR files required by your project
    • classes
      • beans

Therefore you place your UserPack folder in place of beans folder and put that ConnectionBean inside that folder

More documentation can be found on Tomcat website

hey dont put the beans folder...
instead put the folder naming same as ur package...

--classes
----|--package_name (folder)
--------|--class files
--------|--java files

try this it would definitly work..

The name of the folder that holds Beans does not matter, it is by your preferences!
Leaving Java files in folder after server deployment is irresponsible of you...

u r running on ur own server , i suppose not...
i think u r running it on local server, so dnt try to act smart...
that i mentioned at the time of compilation...

1) Start using proper English it is one of the forum rules
2) You did not mention anything, just went on rants that the poster should not put his content in bean folder

i think i used proper english ...
if u didnt understand then go to primary school to learn english...
nd for ur kind information if u would do what i stated ... then u wont face ny problem...

Personal attacks on forum members are not tolerated
Sort your dictionary as there are no English words as u, nd, ur, ny, dnt, r but for sure you, and, your, any, don't, are

just cut the crap off... these are short forms... there is sumthing named as voice... nd these short forms are based on voice.. so try to recognize the sounds.. i was just here to solve ur prob nt to argue with u...
instead of thanking u r arguing..

Please read the whole post. It was not my problem but other member's! I just provided solution.
Please read the forum rules

We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak.

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.