aspose file tools*
The moose likes JSP and the fly likes problem in usebean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in usebean" Watch "problem in usebean" New topic
Author

problem in usebean

kuni patel
Greenhorn

Joined: Jun 04, 2005
Posts: 7
hi
i am developing a application in jsp & i am getting an error in tomcat server on using usebean


Error: 500
Location: /krunaljspbeans/beans.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to load class krunaljspbeans.LanguageBeans




In this,
i create one html->beans.html
in that html i call beans.jsp.

as well as i put those two app,html and jsp in krunaljspbeans package that is in root directiory.ok.

in this jsp i use that usebeans.
that code is:
<html>
<body>

<jsp:useBean id="languageBean" class=" krunaljspbeans.LanguageBeans" />
<jsp:setProperty name="languageBean" property="name" value='<%= request.getParameter("name") %>' />
<p> Hello, <jsp:getProperty name="languageBean" property="name" /><%= LanguageBeans.getName()%></p>
</body>
</html>

and my java class LanguageBeans code is:

package krunaljspbeans;

public class LanguageBeans
{
private String name="unknown";
public String getName()
{
return(name);
}
public void setName(String name)
{
this.name = name;
}
}

i compile that program and put that class in root/webinf/class/krunaljspbeans

after that when i run http://localhost:8080/krunaljspbeans/beans.html
it gives me above error.

so,Plz tell me where i m wrong?
Plz, give me right direction.
Thanx.
[ September 21, 2005: Message edited by: kuni patel ]

Thanx
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Did you create a bean called LanguageBean?
Does it have a setName and a getName method?

Also, your beans will need to be packaged if they are to work in any but the oldest app servers (actually any server using j2se1.4.0 or older).


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by kuni patel:
Thanx Mr/Miss Ben..
But

hi
i am developing a application in jsp & i am getting an error in tomcat server on using usebean


Error: 500
Location: /krunaljspbeans/beans.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to load class krunaljspbeans.LanguageBeans




In this,
i create one html->beans.html
in that html i call beans.jsp.

as well as i put those two app,html and jsp in krunaljspbeans package that is in root directiory.ok.

in this jsp i use that usebeans.
that code is:
<html>
<body>

<jsp:useBean id="languageBean" class=" krunaljspbeans.LanguageBeans" />
<jsp:setProperty name="languageBean" property="name" value='<%= request.getParameter("name") %>' />
<p> Hello, <jsp:getProperty name="languageBean" property="name" /><%= LanguageBeans.getName()%></p>
</body>
</html>

and my java class LanguageBeans code is:

package krunaljspbeans;

public class LanguageBeans
{
private String name="unknown";
public String getName()
{
return(name);
}
public void setName(String name)
{
this.name = name;
}
}

i compile that program and put that class in root/webinf/class/krunaljspbeans

after that when i run http://localhost:8080/krunaljspbeans/beans.html
it gives me above error.

so,Plz tell me where i m wrong?
Plz, give me right direction.
Thanx.


You put them in "root/webinf/class" ?
It should be WEB-INF (case sensitive)
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you would like a working example of JSP/Bean interaction, there is one on my site: http://simple.souther.us.
Look for SimpleBean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in usebean
 
Similar Threads
jsp:getProperty
jsp:usebean
JSP and JavaBeans
Again problem in usebean
unable to compile class for jsp