• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem retrieving javabean instance from request in JSP

 
Dave Robinson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using WSAD and I created a javabean called confirmBean in the default package. It contains two private properties fname, lname and has public setters and getters

In a servlet I placed values in the beans properties, then placed the bean in a request and then forwarded to confirm.jsp

confirmBean cb = new confirmBean();
cb.setFname("testing");
cb.setLname("aaa");
req.setAttribute("mybean", cb);
req.getRequestDispatcher("/confirm.jsp").forward(req,res);

Here is my JSP, I used java syntax for retrieving javabean:

<HTML>
<HEAD>
<TITLE>confirm.jsp</TITLE>
</HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"%>
<%@ page import="confirmBean"%>
<BODY>

<% confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); %>
<%= myBean.getFname() %>

</BODY>
</HTML>

and here is the error i am getting when executing:

Error 500: Unable to compile class for JSP c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\local host\server1\Test\TestWeb.war\_confirm.java:3: '.' expected import confirmBean; ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\local host\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\local host\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ 3 errors

Please help!!!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Starting with Java 1.4.1, you can no longer import non-packaged (default package) classes from packaged classes.

Package your beans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic