Solved

JSP InputStream Help

Posted on 2004-08-02
2
797 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Retrieving file from bytes array in spring mvc 8 60
if statement not resolving in my code 5 52
spring example non maven 4 88
eclipse luna javeEE perspecive missing 5 110
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
Google always has something new and amazing up its sleeve, and the most current thing that they have been working on is another step in the evolution of Google Search, from machine learning to its brilliant successor, deep learning.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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