#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    0
    Rep Power
    0

    Application Development


    Hello, I have a quick question... does JSP have something similar to Coldfusions Application.cfm file? I would like to run some code (say application.jsp) before any of the other files are accessed....

    I know I can include application.jsp in every file, but I would prefer not to. Thanks.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    0
    Rep Power
    0
    ! got another question.... is there any way to include a file using a variable in the include statemen (example below):

    String filename = test.jsp;
    <%@ include file= filename %>

    Thanks.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    5
    Rep Power
    0
    Originally posted by socrates73
    ! got another question.... is there any way to include a file using a variable in the include statemen (example below):

    String filename = test.jsp;
    <%@ include file= filename %>

    Thanks.
    I think you have the two include methods mixed up. The one you've used above is a static include. It only happens on the first compile. It can't be dynamic because it happens before code is run or even generated.

    The method you would use to dynamically include another file is <jsp:include page="test.jsp" flush="true" />. If you want to use a variable you can do it like this:

    <% String filename = "test.jsp"; %>
    <jsp:include page="<%=filename %>" flush="true" />

    you can also send parameters to the included file like this:
    <jsp:include page="test.jsp" flush="true">
    <jsp:param name="parametername" value="parametervalue" />
    </jsp:include>

    The param value can be a variable using the <%=variable %> syntax as well

IMN logo majestic logo threadwatch logo seochat tools logo