You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Antonio Merighi <me...@mail.eng.it> on 2000/02/15 11:28:37 UTC
How to init a JSP
I would like to know how to set init parameters to a JSP.
I saw that for servlets there is the web.xml in WEB-INF,
but I don't know how to use it for a jsp that it isn't under
WEB-INF, but it's in jsp directory, like the snoop.jsp in
"example" context.
I tried to write a web.xml file like:
<web-app>
<servlet>
<servlet-name>
snoop.jsp
</servlet-name>
<jsp-file>
/examples/jsp/snoop.jsp
</jsp-file>
<init-param>
<param-name>
file
</param-name>
<param-value>
/usr/local/etc/jsp/jsp.properties
</param-value>
</init-param>
</servlet>
</web-app>
but it seems it didn't like it.
Where are my mistakes?
Thanks.
Antonio
Re: XML File format
Posted by Laird Nelson <lj...@unix.amherst.edu>.
Brill Pappin wrote:
> I mean, why use this format:
> <init-param>
> <param-name>file</param-name>
> <param-value>/usr/local/etc/jsp/jsp.properties</param-value>
> </init-param>
>
> rather than this format?:
> <init-param name="file" value="/usr/local/etc/jsp/jsp.properties"/>
The second does not permit multiple param-values, for one.
Cheers,
Laird
XML File format
Posted by Brill Pappin <br...@jmonkey.com>.
Quick question:
Why was the XML file set up the way it was?
I mean, why use this format:
<init-param>
<param-name>file</param-name>
<param-value>/usr/local/etc/jsp/jsp.properties</param-value>
</init-param>
rather than this format?:
<init-param name="file" value="/usr/local/etc/jsp/jsp.properties"/>
The second seems much cleaner to me... and is clearer to read when perusing
the file.
- Brill Pappin
www.jmonkey.com
Re: How to init a JSP
Posted by Gunther Schadow <gu...@aurora.rg.iupui.edu>.
your init-param thing seems fine to me, however, you may encounter
a whitespace problem here, I'm not sure.
To remember:
(1) the init-param element repeats for each parameter
(2) try this instead
<init-param>
<param-name>file</param-name>
<param-value>/usr/local/etc/jsp/jsp.properties</param-value>
</init-param>
(3) However, I have no idea why/how you can use the snoop.jsp file
as a servlet. Why do you need init parameters for a jsp page? I
don't understand this, but it doesn't mean it's wrong.
(4) If you have a real servlet, you should have something like
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>org.myorg.mypack.MyServlet</servlet-class>
<!-- init parameters here -->
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
The servlet mapping element turned out to be important for me so that
the servlet would be activated through
URL: http://myhost.org/myservlet
of course you have to make sure that the apache.conf and the server.xml
files also know about your web-app context.
regards
-Gunther
Antonio Merighi wrote:
>
> I would like to know how to set init parameters to a JSP.
> I saw that for servlets there is the web.xml in WEB-INF,
> but I don't know how to use it for a jsp that it isn't under
> WEB-INF, but it's in jsp directory, like the snoop.jsp in
> "example" context.
> I tried to write a web.xml file like:
>
> <web-app>
> <servlet>
> <servlet-name>
> snoop.jsp
> </servlet-name>
> <jsp-file>
> /examples/jsp/snoop.jsp
> </jsp-file>
> <init-param>
> <param-name>
> file
> </param-name>
> <param-value>
> /usr/local/etc/jsp/jsp.properties
> </param-value>
> </init-param>
> </servlet>
> </web-app>
>
> but it seems it didn't like it.
> Where are my mistakes?
> Thanks.
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org