Solved

JSP InputStream Help

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Display the newly inserted values 3 72
caughtSpeeding java challenge 16 132
maven set up 2 104
listing all functions in JavaScript 19 114
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now