Discussions

Web tier: servlets, JSP, Web frameworks: InitArgs for JSP pages

  1. InitArgs for JSP pages (1 messages)

    Hello,
    I am trying to pass initArgs for all JSP pages (I am using Weblogic 5.1), but there is no supporting documentation anywhere that shows exactly how I can do it. I figured that I can just add on to the JSP properties section in weblogic.properties file. That does not seem to work. Here is how my properties file looks:

    ///////////////////////////////
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    # WEBLOGIC JSP PROPERTIES
    # ------------------------------------------------
    # Sets up automatic page compilation for JSP. Adjust init args for
    # directory locations and uncomment to use.
    weblogic.httpd.register.*.jsp=\
           weblogic.servlet.JSPServlet
    weblogic.httpd.initArgs.*.jsp=\
           pageCheckSeconds=1,\
           compileCommand=D:/java/jdk1.3/bin/javac.exe,\
           keepgenerated=true,\
           workingDir=D:/weblogoc/myserver/classfiles,\
           verbose=true,\
           myParameter=somevalue

    //////////////////////////

    This does not seem to work. If I call getInitParameter("myParameter") in my JSP files, it returns null.

    I am not sure if I am doing the right thing by specifying the initArgs in properties file. Is there any place else I need to do so?

    Thanks
    -Hareesh
  2. InitArgs for JSP pages[ Go to top ]

    What you did was specify the initialization params for weblogic.servlet.JSPServlet. I'm not sure if there's a way to specify params for all JSPs through the weblogic.properties file. If you package your JSPs into a web application, you could use <context-param> tags to specify application initialization params which would be accessible to all JSPs and servlets in your web app. You would access them with:

    <%
    String myParameterValue = application.getInitParameter("myParameter");
    %>

    from a JSP file or:

    String myParameterValue = getServletContext().getInitParameter("myParameter");

    from a servlet.

    HTH

    Andy