Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts Users »

Re: request.setAttribute

Honza Spurný

2003-11-28

Replies:

Paul McCulloch wrote:
> Please send some real code. I think you may have over simplfified
> what you are showing us.
>
> Paul

No no, this is realy all :)

look:

public final class CreateServerAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
request.setAttribute("serverBean", new Server());
return(mapping.findForward("success"));
}

}


in apropriate jsp page is used:
<jsp:useBean id="serverBean" class="cz.master.is.tech.server.Server"
scope="request" />

but by my opinion the problem is in the Server class, since it has about 125
attributes (each attribute has setter and getter method), so this object is
realy huge...

>
>> -----Original Message-----
>> From: Honza Spurn? [mailto:spurny@(protected)]
>> Sent: 28 November 2003 12:09
>> To: Struts Users Mailing List
>> Subject: Re: request.setAttribute
>>
>>
>> Paul McCulloch wrote:
>>> Have something print out all of the request scope attributes and see
>>> what's there. I've attached a bit of jsp which I use to
>> diagnose this
>>> sort of issue. Alternatively set a breakpoint in your code after
>>> setting the attribute and have a look in the debugger.
>>>
>>> <bean:page id="this_request" property="request" />
>>> <%
>>>      java.util.Enumeration e2 =
>>> this_request.getAttributeNames();
>>>      while (e2.hasMoreElements()) {
>>> String element =
>>> (String)e2.nextElement();
>>>         out.write("<br>" + element + " : " +
>>> this_request.getAttribute(element).getClass().getName());
>>>         out.write("<br><br>" +
>>> this_request.getAttribute(element).toString() + "<br>");
>>>
>>> }
>>>
>>>
>>> %>
>>
>>
>> The MyObject is there, but always I want it download from
>> request, I get
>> null object.
>>
>> Why?
>>
>>>
>>>
>>> Paul
>>>> -----Original Message-----
>>>> From: Honza Spurn? [mailto:spurny@(protected)]
>>>> Sent: 28 November 2003 11:59
>>>> To: Struts Users Mailing List
>>>> Subject: Re: request.setAttribute
>>>>
>>>>
>>>> Paul McCulloch wrote:
>>>>> It still isn't correct. You staore it as "myObejct" and try and
>>>>> retrieve it
>>>>> as "myObject"
>>>>
>>>> OK OK, that is only overwrite, sorry... but this is not
>>>> copied from code,
>>>> this is written to make easy view of the problem... In code I
>>>> have correct
>>>> values, realy.
>>>>
>>>> so:
>>>> MyObject o = new MyObject();
>>>> o.setObjectName("name");
>>>> request.setAttribute("myObject", o);
>>>>
>>>> MyObject o2 = (MyObject)request.getAttribute("myObject");
>>>>
>>>> if (o2 == null) System.out.println("NULL");
>>>> else System.out.println(o.getObjectName());
>>>>
>>>>
>>>>
>>>>>
>>>>> Paul
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Honza Spurn? [mailto:spurny@(protected)]
>>>>>> Sent: 28 November 2003 11:51
>>>>>> To: Struts Users Mailing List; Honza Spurn?
>>>>>> Subject: Re: request.setAttribute
>>>>>>
>>>>>>
>>>>>> Corrected version:
>>>>>>
>>>>>> MyObject o = new MyObject();
>>>>>> o.setObjectName("name");
>>>>>> request.setAttribute("myObejct", o);
>>>>>>
>>>>>> MyObject o2 = (MyObject)request.getAttribute("myObject");
>>>>>>
>>>>>> if (o2 == null) System.out.println("NULL");
>>>>>> else System.out.println(o.getObjectName());
>>>>>>
>>>>>>
>>>>>> The problem still occures. I'm not able to download from
>>>> request such
>>>>>> MyObject as I have stored in. Can it be caused by the huge
>>>>>> size of object?
>>>>>>
>>>>>> Sporak
>>>>>>
>>>>>>
>>>>>>
>>>>
>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail:
>> struts-user-unsubscribe@(protected)
>>>>>> For additional commands, e-mail:
>>>> struts-user-help@(protected)
>>>>>>
>>>>>
>>>>>
>>>>> **************************************
>>>>> Axios Email Confidentiality Footer
>>>>> Privileged/Confidential Information may be contained in
>>>> this message.
>>>>> If you are not the addressee indicated in this message (or
>>>>> responsible for delivery of the message to such person),
>> you may not
>>>>> copy or deliver this message to anyone. In such case, you should
>>>>> destroy this message, and notify us immediately. If you or your
>>>>> employer does not consent to Internet email messages of this kind,
>>>>> please advise us immediately. Opinions, conclusions and other
>>>>> information expressed in this message are not given or
>>>> endorsed by my
>>>>> Company or employer unless otherwise indicated by an authorised
>>>>> representative independent of this message.
>>>>> WARNING:
>>>>> While Axios Systems Ltd takes steps to prevent computer
>> viruses from
>>>>> being transmitted via electronic mail attachments we cannot
>>>>> guarantee that attachments do not contain computer virus code.
>>>>> You are therefore strongly advised to undertake anti virus checks
>>>>> prior to accessing the attachment to this electronic mail. Axios
>> Systems Ltd
>>>>> grants no warranties regarding performance use or quality of any
>>>>> attachment and undertakes no liability for loss or damage
>> howsoever
>>>>> caused.
>>>>>
>>>>>
>>>>>
>>>>
>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
>>>>> For additional commands, e-mail:
>> struts-user-help@(protected)
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
>>>> For additional commands, e-mail:
>> struts-user-help@(protected)
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
>>> For additional commands, e-mail: struts-user-help@(protected)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
>> For additional commands, e-mail: struts-user-help@(protected)
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
> For additional commands, e-mail: struts-user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
For additional commands, e-mail: struts-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.