aspose 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
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