You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael McGrady <mi...@michaelmcgrady.com> on 2004/01/08 20:59:47 UTC

Action Class to Load Resources: Applets

I use an Action class to load resources, e.g., as follows:

         <html:img src='RESOURCE.do?resource=struts-power.gif'
                          alt='Powered by Struts'
                          height='15'/>.

The class is simple enough, sans utility classes:

public final class ActionResource
     extends Action {
   public ActionForward execute(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response)
       throws IOException,
              ServletException {
     new WriteResponseImpl().write(new 
InitResponseImpl().init(request.getParameter(MimeConstant.RESOURCE), 
response), response);
     return null;
   }
} /// ;-) Michael McGrady HomeSites

I also use this in <OBJECT> tags for Flash, as follows:

<param
       name = "movie"
       value = "RESOURCE.MICHAELMcGRADY?resource=image_with_text.swf" />

and:

<embed
      src = "RESOURCE.MICHAELMcGRADY?resource=image_with_text.swf"
       quality = "high"
       bgcolor = "#ffffff"
       width = "<%= w %>"
       height = "<%= h %>"
       name = "simple_text1"
       align = "middle"
       allowScriptAccess = "sameDomain"
       type  = "application/x-shockwave-flash"
       pluginspage = "http://www.macromedia.com/go/getflashplayer" />
I need to see how to do this with applets in the <object> tag.  Anyone have 
a clue?  I cannot do this with the "codebase" attribute, I think, because 
that is not the entire URL to be accessed and I want to be inside 
WEB-INF.  Can I just deliver the class with the "code" attribute of the 
<OBJECT> tag and the ActionResource class?

Thanks for any assistance.  If you want to get resources inside WEB-INF, 
things are not well documented.  I think I will have this all pretty much 
licked, once I get by the applet dilemma.  Thanks, again, for any ideas.

Michael McGrady