tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: Resolving scriptlets when using a client side <SCRIPT ...> tag?
Date Sun, 06 Jul 2003 05:39:27 GMT
I'd probably go with a Filter (mapped to '*.js') to do this.  I'd rename the
physical something.js files to something.jsp, and the Filter would do
something like:

  ServletContext context = null;
  public void init(FilterConfig conf) {
     context = conf.getServletContext();
  }
  public void doFilter(ServletRequest req, ServletResponse res, FilterChain
chain)
   throws IOException, ServletException {
     if( req instanceof HttpServletRequest ) {
         HttpServletRequest hReq = (HttpServletRequest)req;
         String path = hReq.getPathInfo();
         URL file = context.getResource(path);
         if(file == null) { // not a physical .js file
            String newPath = path + "p"; // Yes, I know it's hacky
            RequestDispatcher rd = context.getRequestDispatcher(newPath);
            rd.forward(req, res);
            return;
         }
    }
    chain.doFilter(req, res);
  }
"Adrian Beech" <a.beech@bigpond.net.au> wrote in message
news:001a01c34354$28476fb0$0200000a@minbari...
> G'day folks,
>
> Is it possible to get Tomcat to process a include file and resolve
embedded
> scriptlets if the file is referenced from a client side <SCRIPT ...> tag?
> In the two .js files I'm trying to work with there are several scriptlets
> that need to be resolved by Tomcat prior to sending the content along to
the
> browser.
>
> I can use <%@ include file=... %> server side which works just dandy,
> however the resulting content is easily visible to the user if they happen
> to view the source of the currently displayed page.  My preference is to
use
> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"
> SRC="Includes/InboundContact_Form.js"></SCRIPT> client side so that the
code
> is not part of the displayable source on the client's browser.
>
> The problem I've run into is that when using a <SCRIPT ...> tag the
> scriptlets are not resolved by Tomcat and what I end up with is something
> like 'var orgName = "<%= orgReference.getOrganisationName() %>";' instead
of
> 'var orgName = "Brisbane City Council";' on the client's side.
>
> Can anyone please help?
>
> AB




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message