This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes How to access an object which is set in request attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to access an object which is set in request attribute" Watch "How to access an object which is set in request attribute" New topic
Author

How to access an object which is set in request attribute

siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 124
Hi,
I faced a problem while developing a strut application.
I am explaining in details.
In my action class I defined an object which is as follows

public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
--------------------
---------------------
Department dept =new Department();
dept.setDno(dno);
request.setAttribute("DEPARTMENT",dept);
if(dept.getFlag())
forward= mapping.findForward("success");
else
forward= mapping.findForward("failure");
return forward;}

But I am unable to access in succes.jsp

<%@ page import="deptPack.Department"%>

and when i wrote
<%=(Department(request.getAttribute("DEPARTMENT"))).getName() %>
The following eror is coming during compilation
"the method defined Department is undefined for the type succes

Please help me.
Thanks in advance
Sidhartha das
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

Siddharth,
Any reason you are using scriptlets instead of Struts tags? (or EL)

With Struts tags, this would be:


If you want to use Scriptlets, the cast looks wrong. It should be:


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access an object which is set in request attribute
 
Similar Threads
Getting Bad Request
Sort array - by two fields
XSLT/XPath - Find unique text node value
Updating the Mapping Table.
Forward in an action forms reset method.