chaitu chaitu
asked on
How to pass the object from one context to another context in struts-websphere combination
How to pass the object in this action class(do we need to set it here in request,session or application scope) from one context to another context and how to access this object in in different context action class.
am using websphere application server.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
index.jsp
<HEAD>
<BODY>
<form action="/employee/EmployeAction">
<input type='text' name='empname' value='1'>
<input type='submit' name='submit' value='submit'>
</BODY>
</HTML>
EmployeAction.javapublic class EmployeAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse httpservletresponse)
throws Exception {
if (form == null) {
return mapping.findForward("success");
}
String empname =request.getParameter("empname");
Employee emp = new Employee();
emp.setName(empname);
// how to store or pass this object here in this action class(do we need to set it here session or application scope) and how to access this object in in different context action //class.
//am using websphere application server.
/dept/DeptAction
return mapping.findForward("success");
}
}
you cannot pass an object to a different context, they are independant applications
try setting the required objects in Session variable , and access them from your desired class/jsp
But it will only be available in that particular HTTP session.
request.getSession().setAt tribute("a ttribute name",object);
But it will only be available in that particular HTTP session.
request.getSession().setAt
ASKER
suraj,
if you are passing object from one context to another context session scope will not work.
objects,
this employee object is having multiple variables and need to pass this object in diff contexts.how to overcome this problem??
if you are passing object from one context to another context session scope will not work.
objects,
this employee object is having multiple variables and need to pass this object in diff contexts.how to overcome this problem??
session is only available in the same context so won't help for sending to a different context
if you're just forwarding within the same context then you should pass it as a request attribute
if you're just forwarding within the same context then you should pass it as a request attribute
to pass to a different context then you'll need to do a redirect and include the details need as request parameters
thanks chaituu and objects for correcting me....
ASKER
objects,
i didnt get you.can you write some pseudo code?
i didnt get you.can you write some pseudo code?
/dept/DeptAction?empName=b ill&empAbc =xyz
ASKER
this is old technique.i need to send some 30 to 40 parameters.if i send like this it will be performance overhead..apart from that i have one xml blob object that i cannot send like this..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.