• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to access an object which is set in request attribute

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic