struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Ventura <vent...@cit.com.br>
Subject Re: request.setAttribute
Date Fri, 28 Nov 2003 12:47:15 GMT
Is this a typo?

> if (s == null) System.out.println(s.getWmId());
> else System.out.println("null");

This will print null if the object is NOT null...

----- Original Message -----
From: "Paul McCulloch" <paul.mcculloch@axiossystems.com>
To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
Sent: Friday, November 28, 2003 10:38 AM
Subject: RE: request.setAttribute


> I'd concentrate on the bit of code in your action:
>
> >     request.setAttribute("serverBean", new Server());
> >     Server s = (Server)request.getAttribute("serverBean");
> >     if (s == null) System.out.println(s.getWmId());
> >     else System.out.println("null");
>
> If this returns null then nothing else is going to work. Try using
different
> classes instead of Server - I'd start with String.
>
> Paul
>
> > -----Original Message-----
> > From: Honza Spurný [mailto:spurny@master.cz]
> > Sent: 28 November 2003 12:33
> > To: Struts Users Mailing List
> > Subject: Re: request.setAttribute
> >
> >
> > Paul McCulloch wrote:
> > > The request attributes are all in a standard HashMap so I very much
> > > doubt there is any intrinsic size limit.
> > >
> > > What shows in your page if you paste in the fragment of jsp I put in
> > > one of my messages?
> > >
> >
> > ...
> > serverBean : cz.master.is.tech.server.Server
> > cz.master.is.tech.server.Server@bb6086
> > ...
> >
> >
> > > Are you sure that you aren't doing a redirect to the jsp?
> >
> > I don't understand well how do you mean it...
> >
> > the fragmnet of struts-config is:
> >
> > <action path="/server/createServer"
> > type="cz.master.is.tech.server.CreateServerAction"
> > input="/server/showServers.do">
> >    <forward name="success" path="/server/editServer.jsp" />
> >   </action>
> >
> > the CreateServerAction i've attached last message.
> >
> > the editServer.jsp uses:
> >  <jsp:useBean id="serverBean" class="cz.master.is.tech.server.Server"
> > scope="request" />
> >
> > Very strange is, that when I try to do in the Action-class this:
> >
> >     request.setAttribute("serverBean", new Server());
> >     Server s = (Server)request.getAttribute("serverBean");
> >     if (s == null) System.out.println(s.getWmId());
> >     else System.out.println("null");
> >
> > NULL always appears... :(
> >
> > >
> > > Paul
> > >
> > >> -----Original Message-----
> > >> From: Honza Spurný [mailto:spurny@master.cz]
> > >> Sent: 28 November 2003 12:22
> > >> To: Struts Users Mailing List
> > >> Subject: Re: request.setAttribute
> > >>
> > >>
> > >> 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@master.cz]
> > >>>> 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@master.cz]
> > >>>>>> 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@master.cz]
> > >>>>>>>> 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@jakarta.apache.org
> > >>>>>>>> For additional commands, e-mail:
> > >>>>>> struts-user-help@jakarta.apache.org
> > >>>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> **************************************
> > >>>>>>> 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@jakarta.apache.org
> > >>>>>>> For additional commands, e-mail:
> > >>>> struts-user-help@jakarta.apache.org
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>
> > >>
> > ---------------------------------------------------------------------
> > >>>>>> To unsubscribe, e-mail:
> > >> struts-user-unsubscribe@jakarta.apache.org
> > >>>>>> For additional commands, e-mail:
> > >>>> struts-user-help@jakarta.apache.org
> > >>>>>>
> > >>>>>
> > >>>>>
> > >>>>
> > >>
> > ---------------------------------------------------------------------
> > >>>>> To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > >>>>> For additional commands, e-mail:
> > >> struts-user-help@jakarta.apache.org
> > >>>>
> > >>>>
> > >>>>
> > >>
> > ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > >>>> For additional commands, e-mail:
> > >> struts-user-help@jakarta.apache.org
> > >>>>
> > >>>
> > >>>
> > >>
> > ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > >>> For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> > >>
> > >>
> > >>
> > ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > >> For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> > >>
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message