You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by BH...@powersystems.rockwell.com on 2005/08/17 21:04:56 UTC
[OT] Passing a DynaForm in a URL inputStream
Sorry for the off topic post,
I have a case where I am generating a struts form and placing it into a
session. I am having to create a inputStream based on a URL of a JSP which
uses the form, but the JSP cannot find the form in any scope. Does the URL
use a different request/session than the action that is creating it? If
so, does anyone know of a way to pass the dynaform to the URL?
Example code:
JSP:
Hello <bean:write name="myForm" property="userName">
ActionClass
public ActionForward execute(final ActionMapping mapping,
final
ActionForm form,
final
HttpServletRequest request,
final
HttpServletResponse response) {
if(null != form){
callFunction(new URL("http://localhost/helloworld.jsp"));
}
return null;
}
Re: [OT] Passing a DynaForm in a URL inputStream
Posted by BH...@powersystems.rockwell.com.
OK, Found an answer for anyone who is interested, If not delete :)
URL url = new URL("http://localhost/helloworld.jsp");
URLConnection conn = target.openConnection();
conn.addRequestProperty("METHOD", "POST");
conn.addRequestProperty("Cookie", "JSESSIONID="+sessionId);
conn.connect();
BufferedReader in = new BufferedReader( new InputStreamReader(
conn.getInputStream() ) );
String inputLine;
StringBuffer pageContent = new StringBuffer();
while ( ( inputLine = in.readLine() ) != null ) {
pageContent.append( inputLine );
}
in.close();
BHansard@powersys
tems.rockwell.com
To
08/17/2005 03:04 user@struts.apache.org
PM cc
Subject
Please respond to [OT] Passing a DynaForm in a URL
"Struts Users inputStream
Mailing List"
<user@struts.apac
he.org>
Sorry for the off topic post,
I have a case where I am generating a struts form and placing it into a
session. I am having to create a inputStream based on a URL of a JSP which
uses the form, but the JSP cannot find the form in any scope. Does the URL
use a different request/session than the action that is creating it? If
so, does anyone know of a way to pass the dynaform to the URL?
Example code:
JSP:
Hello <bean:write name="myForm" property="userName">
ActionClass
public ActionForward execute(final ActionMapping mapping,
final
ActionForm form,
final
HttpServletRequest request,
final
HttpServletResponse response) {
if(null != form){
callFunction(new URL("http://localhost/helloworld.jsp"));
}
return null;
}