tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
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
   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);
    chain.doFilter(req, res);
"Adrian Beech" <> wrote in message
> G'day folks,
> Is it possible to get Tomcat to process a include file and resolve
> 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
> 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
> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"
> SRC="Includes/InboundContact_Form.js"></SCRIPT> client side so that the
> 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
> 'var orgName = "Brisbane City Council";' on the client's side.
> Can anyone please help?
> AB

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message