Including Actions via jsp:include

2001-09-03 Thread Mikkel Bruun

hi Guys,

I bet this has come up before...

I need to include the output of an action in a jsp, using the jsp:include
tag lie this:

jsp:include page=/myAction.do flush=true
jsp:param name=USERID value=CARLOSUS /
/jsp:include

but I get an illegalstate exception, as the ActionServlet forwards instead
of includes...

is there anyway to do this???

thanks

:: 
  Mikkel Bruun
  Senior IT Developer
  [EMAIL PROTECTED]
  Direct: +45 32 88 22 73

  Valtech A/S
  Kanonbaadsvej 10
  DK-1437 Copenhagen
  Tel  +45 32 88 20 00
  Fax +45 32 88 20 20



 -Oprindelig meddelelse-
 Fra: Debasish Ghosh [mailto:[EMAIL PROTECTED]]
 Sendt: 03 September 2001 11:35
 Til: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Emne: Re: Dynamic Forwarding ...
 
 
 Thanks, Ted, for the reply. 
 Actually, I am not forwarding from Action to Action.
 The mapping of the forward dummy resolves to a JSP
 named dummy.jsp and not an action (*.do). 
 
 From an action, on submit, I would like to tansfer
 control to a JSP to accept more inputs. Along with
 this control transfer, I would like to pass a
 parameter to indicate some logic.
 
 I finally did this using a request.getParameter(
 formName ) in the JSP as a scriplet, and declaring a
 hidden property in the JSP :
 html:hidden property=formName value=%= formName
 % /
 
 Now I can access this property from the action class
 of the form dummyForm. Please suggest, if there is a
 better method of doing this (without the scriplet).
 
 Regarding the link that u have mentioned, I had
 already gone thru it. I do not understand one point.
 If I have a form formA, having a property formName,
 then when I forward to another form, formB, how will
 the property be retained as part of formB ? 
 
 Regards.
 
 - Debasish
 
 
 --- Ted Husted [EMAIL PROTECTED] wrote:
  What's in the JSP wouldn't matter, since you are
  going from one Action
  to another. 
  
  If formName is a property in the ActionForm, then it
  shuld be populated. 
  
  I would try using request.getParameter(formName)
  and see if that's
  null too. 
  
  I'd also try hardcoding the value for action to be
  sure that is not
  null. 
  
  If you haven't already, see also 
  
 
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg
 14280.html
  
  
  Debasish Ghosh wrote:
   
   Hi All -
   
   I have trying to implement dynamic forwarding in
  my
   application.
   In the Action class where I am preparing the
  forward
   URL, I am doing the following :
   
   ActionForward fwd = mapping.findForward(dummy);
   StringBuffer path = new StringBuffer(
  fwd.getPath() );
   path.append( ?formName= ).append( action );
   return new ActionForward( path.toString(),
 fwd.getRedirect() );
   
   With this, I am getting the correct parameter to
   ActionForward, and the control is also forwarded
  to
   the appropriate JSP. But I am not able to access
  the
   passed-in parameter. I have a property named
   formName in the called form. But from the action
  of
   the called form, when I access the property
   getFormName(), I get NULL.
   
   In order to achieve this, do I have to declare
   anything in the JSP ?
   
   Please help !!
   
   Regards.
   
   - Debasish
   
   __
   Do You Yahoo!?
   Get email alerts  NEW webcam video instant
  messaging with Yahoo! Messenger
   http://im.yahoo.com
 
 
 __
 Do You Yahoo!?
 Get email alerts  NEW webcam video instant messaging with 
 Yahoo! Messenger
 http://im.yahoo.com
 



Re: Including Actions via jsp:include

2001-09-03 Thread Gregor Rayman

 hi Guys,
 
 I bet this has come up before...
 
 I need to include the output of an action in a jsp, using the jsp:include
 tag lie this:
 
 jsp:include page=/myAction.do flush=true
 jsp:param name=USERID value=CARLOSUS /
 /jsp:include
 
 but I get an illegalstate exception, as the ActionServlet forwards instead
 of includes...
 
 is there anyway to do this???
 
 thanks


I've found one workaround which can help in some situations:

make the Action.perform return null.

include the view (JSP) then.

So it could look like this:

jsp:include page=/myAction.do flush=true
jsp:param name=USERID value=CARLOSUS /
/jsp:include
jsp:include page=/myAction.jsp flush=true /


But it is ugly indeed.

--
gR







SV: Including Actions via jsp:include

2001-09-03 Thread Mikkel Bruun

whoa! 

thanks alot...

does this hack work on all servers???
I have just tested it on tomcat 3.2, will try on Iplanet later...

:: 
  Mikkel Bruun
  Senior IT Developer
  [EMAIL PROTECTED]
  Direct: +45 32 88 22 73

  Valtech A/S
  Kanonbaadsvej 10
  DK-1437 Copenhagen
  Tel  +45 32 88 20 00
  Fax +45 32 88 20 20



 -Oprindelig meddelelse-
 Fra: Gregor Rayman [mailto:[EMAIL PROTECTED]]
 Sendt: 03 September 2001 11:50
 Til: [EMAIL PROTECTED]
 Emne: Re: Including Actions via jsp:include
 
 
  hi Guys,
  
  I bet this has come up before...
  
  I need to include the output of an action in a jsp, using 
 the jsp:include
  tag lie this:
  
  jsp:include page=/myAction.do flush=true
  jsp:param name=USERID value=CARLOSUS /
  /jsp:include
  
  but I get an illegalstate exception, as the ActionServlet 
 forwards instead
  of includes...
  
  is there anyway to do this???
  
  thanks
 
 
 I've found one workaround which can help in some situations:
 
 make the Action.perform return null.
 
 include the view (JSP) then.
 
 So it could look like this:
 
 jsp:include page=/myAction.do flush=true
 jsp:param name=USERID value=CARLOSUS /
 /jsp:include
 jsp:include page=/myAction.jsp flush=true /
 
 
 But it is ugly indeed.
 
 --
 gR
 
 
 
 



Re: Including Actions via jsp:include

2001-09-03 Thread Gregor Rayman

:-) The question is not, whether it works on different servers,
the question is, whether the original including of forwarding 
Action works on some servers.

If the Action.perform returns null, then there is no forward and
no reason for such an exception.


The real problem with this solution is that it breaks the MVC
pattern. In order to make it work, your VIEW (your JSP) which
includes the action, decides how to display the action's results.
It does so by incluing the second *.jsp. 

But this decision should be made by the action itself in cooperation
with the ActionServlet. (The action decides what is the logical
result e.g. success and the action servlet maps it to the 
physical *.jsp or whatever is defined in struts-config.xml)


--
gR


- Original Message - 
From: Mikkel Bruun [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 03, 2001 12:19 PM
Subject: SV: Including Actions via jsp:include


 whoa! 
 
 thanks alot...
 
 does this hack work on all servers???
 I have just tested it on tomcat 3.2, will try on Iplanet later...
 
 :: 
   Mikkel Bruun
   Senior IT Developer
   [EMAIL PROTECTED]
   Direct: +45 32 88 22 73
 
   Valtech A/S
   Kanonbaadsvej 10
   DK-1437 Copenhagen
   Tel  +45 32 88 20 00
   Fax +45 32 88 20 20
 
 
 
  -Oprindelig meddelelse-
  Fra: Gregor Rayman [mailto:[EMAIL PROTECTED]]
  Sendt: 03 September 2001 11:50
  Til: [EMAIL PROTECTED]
  Emne: Re: Including Actions via jsp:include
  
  
   hi Guys,
   
   I bet this has come up before...
   
   I need to include the output of an action in a jsp, using 
  the jsp:include
   tag lie this:
   
   jsp:include page=/myAction.do flush=true
   jsp:param name=USERID value=CARLOSUS /
   /jsp:include
   
   but I get an illegalstate exception, as the ActionServlet 
  forwards instead
   of includes...
   
   is there anyway to do this???
   
   thanks
  
  
  I've found one workaround which can help in some situations:
  
  make the Action.perform return null.
  
  include the view (JSP) then.
  
  So it could look like this:
  
  jsp:include page=/myAction.do flush=true
  jsp:param name=USERID value=CARLOSUS /
  /jsp:include
  jsp:include page=/myAction.jsp flush=true /
  
  
  But it is ugly indeed.
  
  --
  gR