• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP BEAN Question

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to develop a simple JSP+Bean application. I am using Tomcat application.

I have placed my JSP in apache-tomcat-6.0.10\webapps\test.
Added <Context path="/test" docBase="star" debug="1" reloadable="true"/>
in server.xml

Here is my JSP code


here is my JAVA code


i compiled the java code and placed the class file in apache-tomcat-6.0.10\webapps\ROOT\WEB-INF\classes\com\stardeveloper\bean\test.

when i try to run the JSP page , i get an error which mentions "The value for the useBean class attribute com.stardeveloper.bean.test.NumberGuessBean is invalid."

Please advise
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have placed my JSP in apache-tomcat-6.0.10\webapps\test.



i compiled the java code and placed the class file in apache-tomcat-6.0.10\webapps\ROOT\WEB-INF\classes\com\stardeveloper\bean\test.



You put the bean in one web application, and the JSP in another. Of course they're not going to hook up to each other.
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah i realized it

I put my class file in apache-tomcat-6.0.10\webapps\test\WEB-INF\classes

In JSP i changed the below details

<%@ page import = "NumberGuessBean" %>

<jsp:useBean id="numguess" class="NumberGuessBean" scope="session"/>

But i still get the same error. did i do it properly now?
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i removed the package details from java code. I recompiled the code and i get the following error now

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:142)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
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
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amar Naik:
i removed the package details from java code.



Why? That pretty much guarantees that the bean will never be found. It must be in a package.

See the JSP FAQ for details.
[ May 02, 2007: Message edited by: Bear Bibeault ]
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, i am getting confused

My java file is in apache-tomcat-6.0.10\webapps\test\WEB-INF\classes
and jsp file is in apache-tomcat-6.0.10\webapps\test

do i still need a package? If yes what should be the package details
 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i restarted the server and got my application running
I did create a new folder called a in classes directory, added the package details in java code, recompiled , restarted the server

it works now

thanks for the help
 
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic