You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Pingili, Madhupal" <MP...@BBandT.com> on 2004/08/26 20:41:30 UTC

RE: can a non struts application be called from inside stuts appl ication.

In Struts Action, the Servlet URL is prepared like this:
String requestUrl = request.getRequestURL().toString();
String webAppUrl = requestUrl.substring(0, requestUrl.lastIndexOf("/") );
String servlet1Url = webAppUrl + "/servlet1";

This URL is passed to the method getUrlResponse(String url) that I sent
earlier.

HTH,
Reddy Pingili

> -----Original Message-----
> From:	Pingili, Madhupal 
> Sent:	Thursday, August 26, 2004 2:36 PM
> To:	'Struts Users Mailing List'
> Subject:	RE: can a non struts application be called from inside stuts
> appl ication.
> 
> Check this site:
> http://jakarta.apache.org/commons/httpclient/
> 
> -----------
> Reddy Pingili 
> 
> > -----Original Message-----
> > From:	Shilpa Nalgonda [SMTP:snalgonda@mypublisher.com]
> > Sent:	Thursday, August 26, 2004 2:31 PM
> > To:	Struts Users Mailing List
> > Subject:	RE: can a non struts application be called from inside stuts
> > application.
> > 
> > from where do i get this package, and where exactly will doPost method
> > go...i have never used httpClient Package, so can you point me to the
> > correct resource..
> > 
> > -----Original Message-----
> > From: Pingili, Madhupal [mailto:MPingili@BBandT.com]
> > Sent: Thursday, August 26, 2004 2:17 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: can a non struts application be called from inside stuts
> > application.
> > 
> > 
> > How about using HTTP Client package like this:
> >     public static String getUrlResponse(String url) {
> >       String result = null;
> >       HttpClient client = new HttpClient();
> >       // Create a method instance.
> >       HttpMethod method = new GetMethod(url);
> >       // Execute the method.
> >       try {
> >         int statusCode = client.executeMethod(method);
> >       } catch (HttpRecoverableException e) {
> >           //log the error
> >       } catch (IOException e) {
> >           //log the error
> >       }
> >       // Read the response body.
> >       byte[] responseBody = method.getResponseBody();
> >       if( result == null ) {
> >         result = new String(responseBody);
> >       }
> >       // Release the connection.
> >       method.releaseConnection();
> >       return result;
> >     }
> > 
> > In your case, have 3 methods method1, method2 and method3 for 3 servlets
> > and execute them one after the other.
> > 
> > Just try and see if it solves your problem.
> > 
> > ------------
> > Reddy Pingili
> > 
> > 
> > > -----Original Message-----
> > > From:	Shilpa Nalgonda [SMTP:snalgonda@mypublisher.com]
> > > Sent:	Thursday, August 26, 2004 2:03 PM
> > > To:	Struts Users Mailing List
> > > Subject:	RE: can a non struts application be called from inside stuts
> > > application.
> > >
> > > O.k thats great, but i have make a 3 different servlet calls one by
> one
> > in
> > > my action class.
> > > Like  gotoservlet1 then gotoServlet2 and then gotoServlet3,
> > >
> > > how can i achieve that in one action forward...
> > >
> > > -----Original Message-----
> > > From: Jim Barrows [mailto:jbarrows@sssc.com]
> > > Sent: Thursday, August 26, 2004 2:01 PM
> > > To: Struts Users Mailing List
> > > Subject: RE: can a non struts application be called from inside stuts
> > > application.
> > >
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Shilpa Nalgonda [mailto:snalgonda@mypublisher.com]
> > > > Sent: Thursday, August 26, 2004 10:53 AM
> > > > To: Struts Users Mailing List
> > > > Subject: RE: can a non struts application be called from inside
> stuts
> > > > application.
> > > >
> > > >
> > > >
> > > >
> > > > Servlets are accessed by URLs, action classes forward to
> > > > URLs.  So you can
> > > > forward to them, but call them directly akin to a method
> > > > call... I don't
> > > > think so... not without a lot of handwaving and chanting anyway.
> > > >
> > > > >> so you mean to say that i have to rewrite my old servlet
> > > > class into an
> > > > action class.
> > > > My old servlet class which takes httprequest and httpresponse
> > > > and calls do
> > > > post should be converted to an action class execute method having
> the
> > > > functionality of do post method.
> > >
> > > Not really... if your forward can be the URL /gotoMyServlet, then your
> > > okay... it will still work as is.  If in your code you want to do
> > > something
> > > like gotoMyServlet.doPut(blah), then your going to have to do some
> work
> > to
> > > set up the environment that the servlet expects to run in.
> > >
> > >
> > > >
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Jim Barrows [mailto:jbarrows@sssc.com]
> > > > Sent: Thursday, August 26, 2004 1:43 PM
> > > > To: Struts Users Mailing List
> > > > Subject: RE: can a non struts application be called from inside
> stuts
> > > > application.
> > > >
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Shilpa Nalgonda [mailto:snalgonda@mypublisher.com]
> > > > > Sent: Thursday, August 26, 2004 10:37 AM
> > > > > To: Struts Users Mailing List
> > > > > Subject: can a non struts application be called from inside stuts
> > > > > application.
> > > > >
> > > > >
> > > > > i have  a shopping cart struts application, when update
> > > > > button of a jsp is
> > > > > clicked, some action is performed and after the successful
> > > > > excution of that
> > > > > action, a servlet which takes certain parameters should be
> > > > > called from the
> > > > > action class.
> > > > >
> > > > > The servlets which i am talking about are non-struts based
> > > > > and are already
> > > > > implemented, and it would take much time to redo those using
> > > > > struts, so i am
> > > > > wondering if there is any way to reuse those and call those
> > > > > servlets from
> > > > > actions class.
> > > >
> > > > Servlets are accessed by URLs, action classes forward to
> > > > URLs.  So you can
> > > > forward to them, but call them directly akin to a method
> > > > call... I don't
> > > > think so... not without a lot of handwaving and chanting anyway.
> > > >
> > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Jim Barrows [mailto:jbarrows@sssc.com]
> > > > > Sent: Tuesday, August 10, 2004 4:33 PM
> > > > > To: Struts Users Mailing List
> > > > > Subject: RE: Servlet help for a Struts programmer
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Michael McGrady [mailto:mike@michaelmcgrady.com]
> > > > > > Sent: Tuesday, August 10, 2004 1:22 PM
> > > > > > To: Struts Users Mailing List
> > > > > > Subject: Re: Servlet help for a Struts programmer
> > > > > >
> > > > > >
> > > > > > At 12:57 PM 8/10/2004, you wrote:
> > > > > > >Yes, Struts is based on Servlets, but you don't have to know
> > > > > > >anything about Servlets to make a useful Struts webapp.
> > > > > >
> > > > > > I wonder if this is true.  I cannot imagine that it could be.
> > > > > >  Maybe it
> > > > > > is.  I am beginning to think so.  ///;-)
> > > > >
> > > > > Try it yourself.... no JSP's.  No struts, and basic CRUD
> > > > > operations on an
> > > > > address book.
> > > > >
> > > > > Now today, you would probably be smart.  You would have a
> > > > > CRUD servlet for
> > > > > the "actions", that would redirect to a servlet for
> > > > > generating HTML.  That's
> > > > > 4 serlvets handling CRUD, one servlet to generate the
> > > > > add/edit form page,
> > > > > one servlet to generate the list address page.
> > > > >
> > > > > And no, you don't get to use jakarta's ECS either!!!  Nope.
> > > > > Not at all..
> > > > > you can however drool over it :)
> > > > >
> > > > > out.println( "<html>");
> > > > > 	out.println( "<head>");
> > > > > 		out.println( "<title>THis is the title of my
> > > > > page.</title>");
> > > > > 	<out.println( "</head>");
> > > > >
> > > > > Or:
> > > > >
> > > > > out.println( "<html>"
> > > > > 		+"<head>"
> > > > >  		+"  <title>This is the title of my page.</title>");
> > > > > 		+"</head>");
> > > > >
> > > > >
> > > > >
> > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > > For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > > > >
> > > > >
> > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > > For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

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