Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Unable to compile class for JSP(cannot compile bean)
Unable to compile class for JSP [message #650687] Wed, 26 January 2011 04:10 Go to next message
llk  is currently offline llk Friend
Messages: 5
Registered: January 2011
Junior Member
I just started using eclipse today for first time.

I created some JSPs and then created a java bean.

The JSPs were running fine till I added the bean, Now the jsp that uses the bean gives error:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 11 in the jsp file: /SaveName.jsp
UserData cannot be resolved to a type

Not sure what this menas. The java file compiled fine.

Here is the java bean:

public class UserData {
String username;
String email;
String age;

// java BEAN!

public void setUsername( String value )
{
username = value;
}

public void setEmail( String value )
{
email = value;
}

public void setAge( String value )
{
age = value;
}

public String getUsername() { return username; }

public String getEmail() { return email; }

public String getAge() { return age; }
}

Problem is in this line in JSP:

<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>


is it that it cannot find the java class?

Exclipe put the file under "build/classes" directory. Please suggest what is the cause.

thanks

Re: Unable to compile class for JSP [message #650692 is a reply to message #650687] Wed, 26 January 2011 05:50 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 2011.01.25 21:10, llk wrote:
> I just started using eclipse today for first time.
>
> I created some JSPs and then created a java bean.
>
> The JSPs were running fine till I added the bean, Now the jsp that uses
> the bean gives error:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
> An error occurred at line: 11 in the jsp file: /SaveName.jsp
> UserData cannot be resolved to a type
>
> Not sure what this menas. The java file compiled fine.
>
> Here is the java bean:
>
> public class UserData {
> String username;
> String email;
> String age;
> // java BEAN!
>
> public void setUsername( String value )
> {
> username = value;
> }
>
> public void setEmail( String value )
> {
> email = value;
> }
>
> public void setAge( String value )
> {
> age = value;
> }
>
> public String getUsername() { return username; }
>
> public String getEmail() { return email; }
>
> public String getAge() { return age; }
> }
>
> Problem is in this line in JSP:
>
> <jsp:useBean id="user" class="UserData" scope="session"/>
> <jsp:setProperty name="user" property="*"/>
>
> is it that it cannot find the java class?
>
> Exclipe put the file under "build/classes" directory. Please suggest
> what is the cause.
>
> thanks

Shouldn't your use of useBean should be more something like:

<jsp:useBean id="user" class="packagename.UserData" scope="session" />
Re: Unable to compile class for JSP [message #650830 is a reply to message #650692] Wed, 26 January 2011 18:10 Go to previous message
llk  is currently offline llk Friend
Messages: 5
Registered: January 2011
Junior Member
Yes, sir.

Orginally eclipse created the java class in the root package and that is why I did not have user.UserData.

I have now changed it and created a class in the correct folder and it works.

thanks for your reply!
Previous Topic:commons-dbcp / commons-pool usage in Eclipse Plug-in
Next Topic:Plug-in development
Goto Forum:
  


Current Time: Fri Apr 26 23:07:09 GMT 2024

Powered by FUDForum. Page generated in 0.08223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top