Hi Jonas -
To avoid hardcoding, add this to your web.xml (inside
your <web-app>):
<context-param>
<param-name>howtoXSL</param-name>
<param-value>/xsl/howto.xsl</param-value>
</context-param>
<context-param>
<param-name>feedbackXSL</param-name>
<param-value>/xsl/feedback.xsl</param-value>
</context-param>
Then this is your code inside your servlet:
ServletContext ctx = getServletContext();
String howtoXSL =
ctx.getRealPath("/") +
ctx.getInitParameter("howtoXSL");
String feedbackXSL =
ctx.getRealPath("/") +
ctx.getInitParameter("feedbackXSL");
try {
FileInputStream howtoXSLFIS =
new FileInputStream(howtoXSL);
FileInputStream feedbackXSLFIS =
new FileInputStream(feedbackXSL);
// do whatever you wanted to do here...
} catch (IOException ioe) { log( ioe.getMessage() ); }
Hope this helps,
David
--
Jonas Bergstr�m wrote:
> Hello.
>
> Is it possible to include resource files, such as
.xsl files, that are read
> by a servlet (through e.g. a FileInputStream) in a
war file, just as if they
> were read from disk?
>
> How is that file accessed, which path is used?
>
> To be more clear, if the content of my .war is this:
>
> /index.html
> /images/banner.gif
> /images/jumping.gif
> /WEB-INF/web.xml
> /WEB-INF/lib/jspbean.jar
> /WEB-INF/classes/com/mycorp/servlets/MyServlet.class
> /WEB-INF/classes/com/mycorp/util/MyUtils.class
> /xsl/howto.xsl
> /xsl/feedback.xsl
>
> The servlet generates xml on each request, and wants
to transform the xml
> with either 'howto.xsl', or 'feedback.xsl' to
generate output to the client.
>
> Is it now possible for the servlet to read those
.xsl files as if they
> resided on disk?
>
>
>
> Thanks / Jonas
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
>
http://lists.sourceforge.net/lists/listinfo/jboss-user
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user