struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Kumar Boppudi <arunkumar.bopp...@gmail.com>
Subject Re: Reading input stream (xml)
Date Fri, 30 Jul 2010 08:17:21 GMT
Unfortunately, I have to use XML here. So, I cannot use the first
suggestion.

If I use request.getInputStream, subsequent request.getParameter calls will
fail. Will it cause any problems in struts?

I would like to give a try to the third one. But not all the action
controllers gets XML in the request. So, I may have to list down the
controllers which gets the XML content in the request.

-- AB


On Fri, Jul 30, 2010 at 10:41 AM, Rahul Mohan <rahul.mohan@tcs.com> wrote:

> Think I understand your problem now. AFAIK Struts doesn't have any
> available mechanism to handle these. I can suggest the following
> solutions:
> 1. Create your request body in the way Struts is expecting - name-value
> pairs.
>
> 2. Extend struts by creating a custom request processor. ( See:
> http://onjava.com/pub/a/onjava/2004/11/10/ExtendingStruts.html ). You will
> have to identify the first possible hook and call getInputStream to
> extract the info and pass it as a request parameter or invoke a custom
> action since request.getInputStream cannot be called after the request is
> parsed.
>
> 3. Put a custom servlet-filter in front of the struts controller to get
> the request data and re-pass it as a request parameter to struts.
>
> I prefer the first approach which is the easiest and does no harm.
>
> - Rahul
>
>
>
> From:
> Arun Kumar Boppudi <arunkumar.boppudi@gmail.com>
> To:
> Struts Users Mailing List <user@struts.apache.org>
> Date:
> 30-07-2010 09:49
> Subject:
> Re: Reading input stream (xml)
>
>
>
> There is no form and I am sending XML content to the action controller
> using
> Fiddler.
>
> And data sent is not in the format of query string. (not in the format:
> paramname=*xml_content*). So, struts may not be mapping it to a property
> in
> the form bean. In this case, how can I get the posted XML contents?
>
>
> -- AB
>
>
> On Thu, Jul 29, 2010 at 5:59 PM, Rahul Mohan <rahul.mohan@tcs.com> wrote:
>
> > Data goes in request body when you are posting a form. Post requests are
> > obviously handled by Struts. So it should work. ( Only you know that it
> is
> > XML, for Struts its just another String. ) Please see your log for any
> > exceptions in setting the action form. Also try inspecting your request
> > using firebug to see if it is being posted.
> >
> >
> >
> > From:
> > Arun Kumar Boppudi <arunkumar.boppudi@gmail.com>
> > To:
> > Struts Users Mailing List <user@struts.apache.org>
> > Date:
> > 29-07-2010 14:58
> > Subject:
> > Re: Reading input stream (xml)
> >
> >
> >
> > I think we should use the query string format to use the string in
> action
> > form class format. But I am not sending it in the query string format.
> And
> > I
> > am not using multipart encoding. Just sending the XML content in POST
> > body.
> >
> > -- AB
> >
> >
> > On Thu, Jul 29, 2010 at 2:38 PM, Rahul Mohan <rahul.mohan@tcs.com>
> wrote:
> >
> > > Arun,
> > >
> > > Are you doing a POST with multi-part encoding?  If so, a solution
> > similar
> > > to file upload would work for you. If not, then the String in
> > action-form
> > > approach that I posted earlier should work.
> > >
> > > - Rahul Mohan
> > >
> > >
> > >
> > > From:
> > > Arun Kumar Boppudi <arunkumar.boppudi@gmail.com>
> > > To:
> > > Struts Users Mailing List <user@struts.apache.org>
> > > Date:
> > > 29-07-2010 13:34
> > > Subject:
> > > Re: Reading input stream (xml)
> > >
> > >
> > >
> > > Rahul,
> > >
> > > I am not sending XML content as part of the query string, only XML
> > content
> > > will be sent in the request body. As struts framework uses the
> > > getParameter
> > > to populate data into the form beans before calling the execute
> method,
> > we
> > > cannot use the request.getInputStream.
> > >
> > >
> > >
> >
> >
>
> http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=jsp-interest&F=&S=&P=49196
>
> >
> > >
> > >
> > > -- AB
> > >
> > >
> > > On Thu, Jul 29, 2010 at 11:01 AM, Rahul Mohan <rahul.mohan@tcs.com>
> > wrote:
> > >
> > > > Arun,
> > > >
> > > > You can keep a string property on action form and map it to the xml
> > > field
> > > > so that the xml content is available here on page submit. In the
> > action
> > > > class, then you will be able to get the string and parse it using
> any
> > > > available xml parser. I don't think Struts provides any shortcut for
> > > this
> > > > requirement.
> > > >
> > > > - Rahul Mohan
> > > >
> > > >
> > > >
> > > > From:
> > > > Arun Kumar Boppudi <arunkumar.boppudi@gmail.com>
> > > > To:
> > > > Struts Users Mailing List <user@struts.apache.org>
> > > > Date:
> > > > 29-07-2010 10:32
> > > > Subject:
> > > > Re: Reading input stream (xml)
> > > >
> > > >
> > > >
> > > > Actually, I am not uploading a file. I am creating XML from the data
> > > > entered
> > > > into the form and sending it to the action controller in the POST
> > > request
> > > > body. In the action controller, I would like to parse the XML. How
> to
> > do
> > > > it
> > > > in Struts 1.3?
> > > >
> > > > -- Arun Kumar Boppudi
> > > >
> > > >
> > > > On Thu, Jul 29, 2010 at 10:24 AM, Rahul Mohan <rahul.mohan@tcs.com>
> > > wrote:
> > > >
> > > > > Doesn't this link (
> > > http://struts.apache.org/2.0.14/docs/file-upload.html
> > > > )
> > > > > help you?
> > > > >
> > > > >
> > > > >
> > > > > From:
> > > > > Arun Kumar Boppudi <arunkumar.boppudi@gmail.com>
> > > > > To:
> > > > > Struts Users Mailing List <user@struts.apache.org>
> > > > > Date:
> > > > > 28-07-2010 22:09
> > > > > Subject:
> > > > > Reading input stream (xml)
> > > > >
> > > > >
> > > > >
> > > > > If we send XML content in the POST/PUT request to Struts action
> > > > > controller,
> > > > > how to read this content in the Action class?
> > > > >
> > > > > -- AB
> > > > >
> > > > >
> > > > > =====-----=====-----=====
> > > > > Notice: The information contained in this e-mail
> > > > > message and/or attachments to it may contain
> > > > > confidential or privileged information. If you are
> > > > > not the intended recipient, any dissemination, use,
> > > > > review, distribution, printing or copying of the
> > > > > information contained in this e-mail message
> > > > > and/or attachments to it are strictly prohibited. If
> > > > > you have received this communication in error,
> > > > > please notify us by reply e-mail or telephone and
> > > > > immediately and permanently delete the message
> > > > > and any attachments. Thank you
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > =====-----=====-----=====
> > > > Notice: The information contained in this e-mail
> > > > message and/or attachments to it may contain
> > > > confidential or privileged information. If you are
> > > > not the intended recipient, any dissemination, use,
> > > > review, distribution, printing or copying of the
> > > > information contained in this e-mail message
> > > > and/or attachments to it are strictly prohibited. If
> > > > you have received this communication in error,
> > > > please notify us by reply e-mail or telephone and
> > > > immediately and permanently delete the message
> > > > and any attachments. Thank you
> > > >
> > > >
> > > >
> > >
> > >
> > > =====-----=====-----=====
> > > Notice: The information contained in this e-mail
> > > message and/or attachments to it may contain
> > > confidential or privileged information. If you are
> > > not the intended recipient, any dissemination, use,
> > > review, distribution, printing or copying of the
> > > information contained in this e-mail message
> > > and/or attachments to it are strictly prohibited. If
> > > you have received this communication in error,
> > > please notify us by reply e-mail or telephone and
> > > immediately and permanently delete the message
> > > and any attachments. Thank you
> > >
> > >
> > >
> >
> >
> > =====-----=====-----=====
> > Notice: The information contained in this e-mail
> > message and/or attachments to it may contain
> > confidential or privileged information. If you are
> > not the intended recipient, any dissemination, use,
> > review, distribution, printing or copying of the
> > information contained in this e-mail message
> > and/or attachments to it are strictly prohibited. If
> > you have received this communication in error,
> > please notify us by reply e-mail or telephone and
> > immediately and permanently delete the message
> > and any attachments. Thank you
> >
> >
> >
>
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message