HELP REQUIRED.....Error on 'application.getResourceAsStream' in JSP

  • Thread starter Attiq ur Rehman
  • Start date
A

Attiq ur Rehman

Hi All,

I'm getting error when I use the following code


String XSL_STYLESHEET="/custom/test.xsl";

InputStreamReader inXsl =
new InputStreamReader(application.getResourceAsStream(XSL_STYLESHEET));




I get the following error:

Method getResourceAsStream(java.lang.String) not found in interface
javax.servlet.ServletContext. InputStreamReader inXsl = new
InputStreamReader(application.getResourceAsStream(XSL_STYLESHEET));

I have JDK 1.3 installed on windows 2000, and I'm using Apache server
with Oracle 9i,


On another machine, I have JDeveloper 9.0 installed and the above
given code works fine there.

Any hint how I can solve it.


Thanks in advance.


With Regards,
Attiq ur-Rehman
 
R

Rhino

Attiq ur Rehman said:
Hi All,

I'm getting error when I use the following code


String XSL_STYLESHEET="/custom/test.xsl";

InputStreamReader inXsl =
new InputStreamReader(application.getResourceAsStream(XSL_STYLESHEET));




I get the following error:

Method getResourceAsStream(java.lang.String) not found in interface
javax.servlet.ServletContext. InputStreamReader inXsl = new
InputStreamReader(application.getResourceAsStream(XSL_STYLESHEET));

I have JDK 1.3 installed on windows 2000, and I'm using Apache server
with Oracle 9i,


On another machine, I have JDeveloper 9.0 installed and the above
given code works fine there.

Any hint how I can solve it.
What class is the object 'application'?

It would appear that 'application' belongs to a class that doesn't have a
getResourceAsStream() method in JDK 1.3. It appears that the JDK you are
using in JDeveloper *does* have a getResourceAsStream() method so it is
probably a JDK that is newer than 1.3.

You'll probably have to upgrade the JDK you are using to the same level as
the one on the machine running JDeveloper.

Rhino
 
M

Malte

Attiq said:
Hi All,

I'm getting error when I use the following code


String XSL_STYLESHEET="/custom/test.xsl";

I fought this for a long time and came up with this generic solution:

WEB-INF/xsl has all my xsl files
WEB-INF/conf has all my configuration files
WEB-INF/log has all my log files

JSP has code like this:

String where_are_my_files =
this.getServletConfig().getServletContext().getRealPath("/WEB-INF/xsl/"));

IMHO, this is very clean and portable.

There are also standard api's to handle extraction of strings from your
your web.xml file:

<context-param>
<param-name>stylesheet-directory</param-name>
<param-value>/WEB-INF/xsl</param-value>
<description>Location of xsl stylesheets</description>
</context-param>
 
A

Attiq ur Rehman

Rhino said:
What class is the object 'application'?

It would appear that 'application' belongs to a class that doesn't have a
getResourceAsStream() method in JDK 1.3. It appears that the JDK you are
using in JDeveloper *does* have a getResourceAsStream() method so it is
probably a JDK that is newer than 1.3.

You'll probably have to upgrade the JDK you are using to the same level as
the one on the machine running JDeveloper.

Rhino


Hi,

Thanks for reply.

Even if I use the following code, I get the same type of error. I just
want to know if there is any special configutration in Apache server
to run the code.

I changed the code to the following one:

String XSL_STYLESHEET="/custom/test.xsl";


InputStreamReader inXsl = new
InputStreamReader(this.getServletConfig().getServletContext().getResourceAsStream(XSL_STYLESHEET));


I get the following error:

Method getResourceAsStream(java.lang.String) not found in interface
javax.servlet.ServletContext. InputStreamReader inXsl = new
InputStreamReader(this.getServletConfig().getServletContext().getResourceAsStream(XSL_STYLESHEET));



Regards,
Attiq
 
M

Malte

Attiq said:
I get the following error:

Method getResourceAsStream(java.lang.String) not found in interface
javax.servlet.ServletContext. InputStreamReader inXsl = new
InputStr

FWIW, my finding, and I may be wrong, is that using getResourceAsStream
is about the slowest possible method of finding anything along the
CLASSPATH.

If you use J2EE, you might as well make use of the J2EE way of finding
stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top