Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSP InputStream Help

Posted on 2004-08-02
2
Medium Priority
?
807 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 750 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

926 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