|
<SERVLET>
<SERVLET-NAME>whatever you want to refer to it as.
can be same as name of jsp (eg.
myfile.jsp)</SERVLET-NAME>
<JSP-FILE>myfile.jsp</JSP-FILE>
<INIT-PARAM>
<PARAM-NAME>propfilevariable</PARAM-NAME>
<PARAM-VALUE>propfilename</PARAM-VALUE>
</INIT-PARAM>
</SERVLET>
You'll
notice that its almost identical to what you would use for a servlet because a
JSP IS a servlet.
Hope
that helps,
-Tim
Senior
Application Technical Specialist
727-738-3000 x 6549
Thanks. I'd like to know exactly what do I need to put in the web.xml
file. Can you please give me more details on that?
Thanks.
Jian
A
JSP page is nothing more than a servlet. Therefore, anything u can do in a
servlet u can do in a jsp page. That includes the init() method. If you look
up the lifecycle of a JSP pg. There is a method called _init() that is
called just like init() for Servlets. Override that method in a jsp
declaration. You use any code that you normally would in the Servlet in this
code as well. Since you are using weblogic. you should also put an
init-param for the jsp file into the web.xml file for the application.
Unless you are getting things from the context.
-Tim
Hi Jian:
I am not exactly going to answer your question, but you could
circumvent the problem as follows:
At the head of your jsp check for the existance of a session variable,
say, "filename". If the value is null, then redirect to your servlet.
This will initialise the servlet (and therefore rad the init param)
and after that the doGet() method will be called. In the doGet(), set
the session variable called "filename" and redirect to the initial jsp.
Now when you check for the "filename" session variable, you will not
get null.
Regards, Geeta
"Ouyang, Jian" wrote:
Hi,This may be a little off
topic.The web server can be set
up such that the property file name can be pick up within the init()
method within a servlet. Can I do the same with JSP
page?I want to know if (and how)
we can set up the web server so the first JSP page can pick up the
property file name. If this can be done with JSP, then I don't need to
hard code the file name and the path in the JSP page. Our web server is
set up such that the servlet will not be hit until the request is being
sent from a page. So to get the property file name from a servlet will
not work for me (it is too late). We use weblogic web
server.Thanks.Jian
|