• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call java action method from JSP (Struts 2)  RSS feed

 
Cristian Adinanda
Greenhorn
Posts: 14
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I quite new in the Sruts 2 tags.
I hit problem during call java action method from my JSP
example :
<s:include value="application_info.action?do=LoadApplicationHeader" />
it will give me error as per below and not even hit my java action:
<Included resource or file "/../../../application_info.action" not found from requested resource "/../../../application_summary_frame.jsp".>

however if i use iFrame  for example as per below, my code working fine
<iframe name="headerFrame" src="<s:url value="application_info.action?do=LoadApplicationHeader"/>" ></iframe>


Please kindly advise.


Thanks and Regards,
Cristian
 
Dave Tolls
Ranch Hand
Posts: 2434
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the iframe tag is used on the client, and the struts tag is on the server.

The former gets the client browser to make a request based on the given RL.
The latter is an include on the server and simply looks for a file with the given name relative to where the JSP file is (I think).
It's not intended as a request.
 
Cristian Adinanda
Greenhorn
Posts: 14
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,

thanks for your explanation.
However, do you have any idea to solve this problem because for UI eason i could not use iFrame.
Is there any way / workaround to use <s:include or <Jsp:include  or another tag?


Thanks and Regards,
Cristian
 
Joe Ess
Bartender
Posts: 9400
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the include tag documentation, it states "Include a servlet's output (result of servlet or a JSP page)."  You aren't trying to include a servlet or JSP tag.  You probably want to use the action tag.
 
Cristian Adinanda
Greenhorn
Posts: 14
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

i tried to use <s:action , there is no error printed, but the jsp also didn't printed out.
it working fine if i use iframe, is it because there is <iframe as well in the outer layer?

my project strucuture :
<iframe > header
<iframe > body
       <s:action >             //this action will call method in java, and return JSP , if i use <iframe here then the result JSP will be printed.
  <iframe > footer

Thanks and Regards,
Cristian
 
Joe Ess
Bartender
Posts: 9400
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't speculate what's wrong from what you describe.  Can you show us code that actually works? 
 
Cristian Adinanda
Greenhorn
Posts: 14
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:I can't speculate what's wrong from what you describe.  Can you show us code that actually works? 


Hi Joe,

Sorry for late reply.
Below code works fine :
<iframe name="current_app_edit" frameborder="NO" width="100%" height="10%"
        src="<s:url value='/app.action?do=LoadHeader'/> "></iframe>

how ever if remove the iframe and use <s:action or ><s:include directly, it will not show my JSP.

Is there any other way to call ><s:url value='/app.action?do=LoadHeader'/> without using iFrame?


Thanks and Regards,
Cristian
 
Cristian Adinanda
Greenhorn
Posts: 14
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

reason why i cannot use iframe because of the project strcuture

                                 header iframe
1 iframe click detail ->
                                 content iframe

if from 1 iframe become 2 iframe as above, i couldnot control the iframe height ended up the page will be very long ( header and content iframe follow the first iframe height ).
 
Joe Ess
Bartender
Posts: 9400
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, this is not enough information to understand what is going on.  Have a look at this article and see if you can give us some more details.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!