Solved

JSP InputStream Help

Posted on 2004-08-02
2
799 Views
Last Modified: 2008-01-16
hi
Can anyone help me on XSL transformer path using JSP.  I have this JSP
<%
Transformer transformer = tFactory.newTransformer(new StreamSource("../../java/MSquaredWeb/stylesheets/right_live.xsl") );
%>

How can I get rid of only partial path "../../java/MSquaredWeb" which is hardcorded and get dynamic content name.

I was told to use this belwo and get ... but have no idea how to use....

ServletContext context = getServletContext();
InputStream is = context.getResourceAsStream("/stylesheets/<name of your stylesheet>");

Only this should be harded coded "stylesheets/right_live.xsl" and rest should be the content name whatever Tomcat is using.

plz help
0
Comment
Question by:princehyderabad
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 250 total points
ID: 11701825
Have you tried using it?

getResourceAsStream does work off the context of the class used to call it...

so as long as you have:

webapps/YourApplication/stylesheets/whatever.xml

then

ServletContext context = getServletContext();
InputStream is = context.getResourceAsStream("/stylesheets/whatever.xml");

should work...
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11704440
actually...thinking about it, I am not sure where the context is set to for jsps...  You may need to move your "stylesheets" directory into WEB-INF/classes
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
constructor overloading 2 86
TreeSet comparator example 7 97
Suggestion on WebSite Template Sites 6 108
eclipse buid path vs tomcat lib path 10 34
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question