RE: getServletContext()

2001-06-27 Thread Stefan Neumann

Hi,

getAttribute returns a java.lang.Object so you have to cast it to
java.sql.Connection. You will also need to import java.sql.

%@ page import=java.sql.* %
...
% Connection Conn =
(Connection)getServletContext().getAttribute(dbConnection); %

Make sure dbConnection isn't null when you set the attribute, cause that
would be
another problem.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 26. Juni 2001 21:06
To: [EMAIL PROTECTED]
Subject: getServletContext()


Hi, I have a problem I have been trying to solve for a very long time. I
first have a initialization servlet set by load_on_startup tag. In this
servlet I create a database connection and pass it to the ServletContext
like
this.

getServletContext().setAttribute(dbConnection,dbConnection);

Now the problem is how do I retrieve it from a jsp page. From by research,
reading through books it shows how to get an attribute using : jsp:useBean
action. However this is done if Beans/Objects are put into the setAttribute.
In my case it is a database connection object. How do I retrieve this from a
jsp page???
I tried (in a jsp page);
% Connection connection = getServletContext().getAttribute(dbConnection);
%
but this returns a null. Connection never gets set..
If someone can help me please..




RE: web.xml not working

2001-06-27 Thread Stefan Neumann

give that one a try:

url-pattern/story/*/url-pattern

using SERVERNAME/sampleapp/story



-Original Message-
From: Erin Lester [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 26. Juni 2001 16:25
To: [EMAIL PROTECTED]
Subject: web.xml not working


I have created a web application as per the Servlet API specs and deployed
it into the webapps directory of Tomcat in a directory called 'sampleapp.'

The only way that I am able to access the webapp's servlet (which is in
sampleapp/WEB-INF/classes) is by the url
'SERVERADDRESS/sampleapp/servlet/SERVLETNAME' and this is only when I
don't have a web.xml file in the WEB-INF directory.  When I place the
web.xml file that I created (using to the documents on the Sun and
Jakarta sites) I am unable to find my servlet.

The servlet mapping in the web.xml file looks like this:

servlet
servlet-nameStoryGeneratorServlet/servlet-name 
servlet-classStoryGenerator/servlet-class 
/servlet

servlet-mapping
servlet-nameStoryGeneratorServlet/servlet-name 
url-pattern/story/url-pattern 
/servlet-mapping

I tried using the urls 'SERVERNAME/sampleapp/servlet/story' and
'SERVERNAME/sampleapp/story'

I also tried to install the J2EE sample 'petstore' web application but had
problems accessing the servlets with it too.  I am able to get to the jsps
and static files okay.

Does anyone know what I am doing wrong? 

Thanks!
Erin

PS - I'm using Tomcat 3.2 with Apache 1.3 on Sun 2.7



Tomcat + FOP, missing method in org.w3c.dom.Node

2001-06-26 Thread Stefan Neumann

Hi,

I try to use FOP 0.17.0 with Tomcat 3.22

It seems that FOP is calling a method from the org.w3c.dom.Node.class that's
not
available. Is it possible that Tomcat insists on using the Node.class that
is
part of parser.jar in the Tomcat/lib-directory ??

I already tried to put xalan.jar and xerces.jar into this directory and
added
two lines to tomcat.bat:

if exist %TOMCAT_HOME%\lib\xerces.jar set
CP=%CP%;%TOMCAT_HOME%\lib\xerces.jar
if exist %TOMCAT_HOME%\lib\xalan.jar set
CP=%CP%;%TOMCAT_HOME%\lib\xalan.jar

but it doesn't help:

javax.servlet.ServletException: org.w3c.dom.Node: method
getNamespaceURI()Ljava/lang/String; not found
at org.apache.fop.apps.Driver.buildFOTree(Driver.java, Compiled Code)

Thanks for any hint




RE: Tomcat + FOP, missing method in org.w3c.dom.Node

2001-06-26 Thread Stefan Neumann

NOW IT WORKS :)

For those with similar problems:
xalan.jar and xerces.jar are in the Tomcat-lib-folder and the relevant part
of the tomcat.bat is

rem - Set Up The Runtime
Classpath --

:setClasspath
set
CP=%TOMCAT_HOME%\lib\xalan.jar;%TOMCAT_HOME%\lib\xerces.jar;%TOMCAT_HOME%\cl
asses

Thank a lot to Randy!


-Original Message-
From: Randy Layman [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 26. Juni 2001 13:41
To: [EMAIL PROTECTED]
Subject: RE: Tomcat + FOP, missing method in org.w3c.dom.Node



Strange, it should have worked, oh well...
There will be a place in tomcat.bat file labeled :setClasspath.
You want to replace
:setClasspath
set CP=%TOMCAT_HOME%\classes
with
:setClasspath
set CP=xalan.jar;xerces.jar;%TOMCAT_HOME%\classes

Be sure to make the paths to xalan and xerces are correct.

Randy




RE: open xml/xsl files inside classpath

2001-06-26 Thread Stefan Neumann

Or at least a way where the path is relative to the web application?

You can use getResourceAsStream() of the ServletContext.

Stefan

-Original Message-
From: Pedro Salazar [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 26. Juni 2001 15:24
To: [EMAIL PROTECTED]
Subject: open xml/xsl files inside classpath


Greetings,

I have a servlet which read some properties (using the ResourceBundle)
from a properties file in a package PT.teste.props where exists a
relation like this:


fileA.xml = file1.xsl
fileB.xml = file2.xsl
...


Of course getting the properties file is simple task because I just use
the location in classpath, ex:

rb=ResourceBundle.getBundle(PT.teste.props.+properties_file);

But, now I would like to open both files, the xml and the xsl file,
which are in a package PT.teste.xml. I tested using the absolute path to
them, but is not very recommendable because tomorrow I probably will put
it in another location or in another machine...


Source xmlSource = new javax.xml.transform.stream.StreamSource (new
java.net.URL(file:///opt/jakarta-tomcat-3.2.1/webapps/servlet_teste/WEB-INF
/classes/PT/teste/xml/fileA.xml).openStream());
Source xslSource = new javax.xml.transform.stream.StreamSource (new
java.net.URL(file:///opt/jakarta-tomcat-3.2.1/webapps/servlet_teste/WEB-INF
/classes/PT/teste/xml/file1.xsl).openStream());


Is there a easy way to open a file in a classpath directly? Or at least
a way where the path is relative to the web application? A not very
recommendable way just to solve my problem is use a path in a properties
file which I would read in the init() of servlet... but, I wouldn't like
to do it!

thanks,
Pedro Salazar.