• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to create an instance of my java bean  RSS feed

 
yogesh srinivasan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a class User.java which is a bean class and deployed it under web-inf\classes folder.
I tried to create an instance of it from an jsp and it container was unable to find it, but it works fine when accessed from a servlet.

-----

<html>
<body>
Hai this is jsp
${userAttrib.uname}

for property
<%-- jsp:useBean id="userAttrib" class="User"/>

<jsp:getProperty name="userAttrib" property="uname"/ --%>
<% User obj= new User(); %>
<% obj.setUname("kaka"); %>
Scriplet obj username is <%=obj.getUname() b%>
</body>
</html>


-----------


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:
JSP FileName:/test.jsp
Java FileName:/C:/tomcat/work/Catalina/localhost/book//org/apache/jsp\test_jsp.java

An error occurred at line: 9 in the jsp file: /test.jsp
User cannot be resolved to a type
6: <%-- jsp:useBean id="userAttrib" class="User"/>
7:
8: <jsp:getProperty name="userAttrib" property="uname"/ --%>
9: <% User obj= new User(); %>
10: <% obj.setUname("kaka"); %>
11: Scriplet obj username is <%=obj.getUname() %>
12: </body>





 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the JSP FAQ entry on this issue?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it's WEB-INF, not web-inf. Please read this for more information.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!