Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP BEAN Question

 
Amar Naik
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic