Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts 2 action to Struts 1 action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 action to Struts 1 action" Watch "Struts 2 action to Struts 1 action" New topic

Struts 2 action to Struts 1 action

Ram ank

Joined: Apr 28, 2011
Posts: 10

I have two applications one running on struts 1 and other on struts 2. Now i need to call action in strtus 1 application from struts2 and parse the response.
I am using

URL url = new URL("/???/");
URLConnection conn = url.openConnection();
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());


// Get the response
StringBuffer response = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

but i am getting error saying Error no protocol. I am not sure this is right way to connect or not.
Joe Ess

Joined: Oct 29, 2001
Posts: 8834

A URL starts with a protocol. You want to use HTTP, but a URL can also be used to access resources with other protocols like FTP, FILE, Gopher and many others.
Uniform Resource Locators (URL) RFC 1738

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ram ank

Joined: Apr 28, 2011
Posts: 10
That worked Thank You. I thought if i give only relative path it would call on local server but it don't.
subject: Struts 2 action to Struts 1 action
Similar Threads
Servlet call another context
HttpURLConnection - Luanch Browser
HttpUrlConnection - cXML PunchOutSetupRequest
how to wait my class for the servlet response