my dog learned polymorphism*
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 Android Security Essentials Live Lessons this week in the Android 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
 
Don't get me started about those stupid light bulbs.
 
subject: Problem retrieving javabean instance from request in JSP
 
Similar Threads
using h:inputHidden in JSF
How do I fill the radio button value from indexId bean
Edit JSP or Servlet refresh error
Have problem when I run jsp on server.
problem with connectiing to oracle from WSAD