File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Problem retrieving javabean instance from request in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem retrieving javabean instance from request in JSP" Watch "Problem retrieving javabean instance from request in JSP" New topic
Author

Problem retrieving javabean instance from request in JSP

Dave Robinson
Greenhorn

Joined: May 11, 2005
Posts: 4
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

Joined: Dec 11, 2004
Posts: 13410

Starting with Java 1.4.1, you can no longer import non-packaged (default package) classes from packaged classes.

Package your beans.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem retrieving javabean instance from request in JSP
 
Similar Threads
using h:inputHidden in JSF
Edit JSP or Servlet refresh error
Have problem when I run jsp on server.
problem with connectiing to oracle from WSAD
How do I fill the radio button value from indexId bean