XSL Stylesheet transformation in a servlet

2003-04-04 Thread JS
Hi there Group.
Not sure if anyone can help me with this here, but worth a shot.
I was hoping someone would be able to help me with some code that Ive
knocked up to test JDOM being used in a servlet.
Quick Synopsis:
Servlet gets hold of a stylesheet in its init() method and caches for
future reuse.The doGet() method then sets up a database connection, uses the
JDOMResultSetBuilder to get an XML representation of the record and uses
this as the XMLSource. A transformation is then done on the XMLSource and
I want this to be output to the browser for display.Everything compiles
OK, I have setup tomcat, webxml, and jar files appropriately and the
Servlet runs using http://127.0.0.1:8080/mywebapp/servlet/JDOMServlet.Many thanks for 
taking the time to read this. Much appreciated.
Rgds

JS


I'm not sure how right my code is, but it runs with no output. Here's the
code..
import javax.servlet.*;
import javax.servlet.http.*;

import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.transform.*;
import org.jdom.JDOMException;
import org.jdom.contrib.input.ResultSetBuilder;

import java.sql.*;
import java.io.*;
import java.io.IOException;
import java.lang.*;

public class JDOMServlet extends HttpServlet {

private TransformerFactory tFactory =
TransformerFactory.newInstance();private String url = 
jdbc:odbc:StudentDB;
private ResultSet rs = null;
private StreamSource xsltSource;

public void init(ServletConfig config) throws ServletException {
super.init(config);

ServletContext context = config.getServletContext();
try {
//Want to cache the stylesheet for future resuse
//then it doesnt have to be loaded constantly
xsltSource = new

StreamSource(context.getResourceAsStream(/Web-Inf/viewStudentDetails.xsl));//---I
 think this is the problem line, it is LINE 35 --//
Templates templates =
tFactory.newTemplates(xsltSource);}
catch (TransformerConfigurationException tce) {
tce.printStackTrace();
}

}

public void doGet(HttpServletRequest request, HttpServletResponse
response)throws ServletException, java.io.IOException {

response.setContentType(text/html);

//setup the database connection and use the
ResultSetBuilder to generate//a JDOM XML document of a 
students details
try {
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection conn =
DriverManager.getConnection(url,,);
Statement stmt = conn.createStatement();
System.out.println(Connected to database);

Namespace ns = Namespace.getNamespace(xhtml,
http://w3.org/etc;);
rs = stmt.executeQuery(SELECT * FROM tblStudent
WHERE StudentID =9917217);
   
System.out.println(Executing query:SELECT * FROM
tblStudent WHEREStudentID = 9917217); 
  
ResultSetBuilder builder = new
ResultSetBuilder(rs);Document doc = 
builder.build();
XMLOutputter xOutputter = new XMLOutputter(  
 , true);xOutputter.output(doc, 
System.out);

//get the JDOM document that was produced by the
JDOM ResultSetBuilder//and convert to 
a normal dom document for use by
the transformerprocessor   

org.jdom.output.DOMOutputter dOutputter = new  
  org.jdom.output.DOMOutputter();   
org.w3c.dom.Document domDocument =
dOutputter.output(doc);
Source xmlSource = new
javax.xml.transform.dom.DOMSource(domDocument);
//create the output result for the newly created
XSLT document//this will allow me to 
output the result to the
browserStreamResult result = new 
StreamResult
response.getOutputStream());//get the 
transformer
System.out.println(Preparing to create

RE: XSL Stylesheet transformation in a servlet

2003-04-04 Thread JS
Hi Yoav,
Much appreciated for your analysis. Many thanks.
I have a few questions.
(1) When u say overide the init() method with the version with the config
parameter, which version is this. public void init(ServletConfig config)
is the only signiature I can find.(2)All the System.out.println commands
in my servlet go to catalina.out in the logs directory. I dont actualy
have a console output.(3) xOutputter.output(doc, System.out); Do you get
any output to System.out? This does come, it was the xmlfile that was in
my original mail, again, it also went to catalina.out. Does the WEB-INF
ile have to be capatilised. I actually have it on my system as
Web-inf.(4)Correct!, TransformerConfigurationException is the root
cause. The only refernece to my program in the stack trace is at
JDOMServlet.init(JDOMServlet.java:35) which is the line I highlighted
below.
 Howdy,

Not sure if anyone can help me with this here, but worth a shot.

 This sort of thing should be marked as [OFF-TOPIC] in the subject if
 you're going to post if to the list at all.

public void init(ServletConfig config) throws ServletException
 {

 Override the init() method, the version with the config parameter,
 instead of this version.

xsltSource = new
StreamSource(context.getResourceAsStream(/Web-
Inf/viewStudentDetails.xsl));//---I think this is the problem
 line, it
is LINE 35 --//

 Print out what getResourceAsStream() produces.  Make WEB-INF
 capitalized in the argument, as this is case sensitive.

Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);

 Yikes ;)  I dislike JdbcOdbc bridges but we'll leave that for now.

ResultSetBuilder(rs);

 Print out the result set contents just to verify them.

xOutputter.output(doc, System.out);

 Do you get any output to System.out?

java.net.MalformedURLException
at java.net.URL.init(URL.java:613)
at java.net.URL.init(URL.java:476)
at java.net.URL.init(URL.java:425)

 But the root causes was a TransformerConfigurationException it appears,
 from the bottom of your output, right?

 Yoav Shapira
 Millennium ChemInformatics



 This e-mail, including any attachments, is a confidential business
 communication, and may contain information that is confidential,
 proprietary and/or privileged.  This e-mail is intended only for the
 individual(s) to whom it is addressed, and may not be saved, copied,
 printed, disclosed or used by anyone else.  If you are not the(an)
 intended recipient, please immediately delete this e-mail from your
 computer system and notify the sender.  Thank you.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



no localhost but 127.0.0.1:8080 works

2003-04-04 Thread JS
Hi Group,
I have a problem here, my setup no longer responds to
http://localhost:8080/blahblah.It works if I use the IP addy, 127.0.0.1:8080, but 
I think this is causing
some problems within tomcat with its own internal references.
Does anyone know how I can fix this. I vaguely recall reading about a
hosts file in System32 folder of windows but cant remember for the life
of me what it was talking about.
Thanks
JS



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: no localhost but 127.0.0.1:8080 works

2003-04-04 Thread JS
Thank you to all those who replied to my earlier query.
Unfortunately, I'm still not having any luck.

From the advice given, I have a hosts.sam file and a hosts (note, no
extension) in my C:\windows directory. I am using Win 98 and Tomcat 4
Is there any other reason as to why localhost:8080 would not work, my port
reference in server.xml is still 8080 as well so I see no reason for the
problems.
Thanks again


 Of course, if you use my example path for winnt below be sure to lean
 the last two name seperators to the left instead of the right...my
 fingers just have trouble with those sometimes...

 -chris

 -Original Message-
 From: Halstead, Chris
 Sent: Friday, April 04, 2003 1:25 PM
 To: Tomcat Users List; [EMAIL PROTECTED]
 Subject: RE: no localhost but 127.0.0.1:8080 works


 If you are on Windoze NT/2000 check
 c:\winnt\system32\drivers/etc/hosts.  I think the Win9x variants use
 c:\windows\etc or c:\windows\system\etc, I don't remember which.  The
 hosts file there should have an entry for 'localhost' that maps to
 127.0.0.1.

 -chris

 -Original Message-
 From: JS [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 04, 2003 1:16 PM
 To: [EMAIL PROTECTED]
 Subject: no localhost but 127.0.0.1:8080 works


 Hi Group,
 I have a problem here, my setup no longer responds to
 http://localhost:8080/blahblah.It works if I use the IP addy,
 127.0.0.1:8080, but I think this is causing some problems within tomcat
 with its own internal references.
 Does anyone know how I can fix this. I vaguely recall reading about a
 hosts file in System32 folder of windows but cant remember for the
 life of me what it was talking about.
 Thanks
 JS



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Can't access my servlet

2003-04-03 Thread JS
Hi there,
I was just wondering, does this action have to be performeed with all
servlets produced??
Thanks


 Many thanks!!!  I added this entry to the web.xml
   servlet-mapping
servlet-nameTestServlet/servlet-name
url-pattern/TestServlet/url-pattern
/servlet-mapping
 and was able to access it with this url:
 http://localhost:8080/stcecilia/TestServlet

 Thanks,
 Lori

 - Original Message -
 From: Tam, Michael [EMAIL PROTECTED]
 To: 'Tomcat Users List' [EMAIL PROTECTED]
 Sent: Wednesday, April 02, 2003 7:14 PM
 Subject: RE: Can't access my servlet


 you need url mapping for your servlet in your web.xml file.  Servlet
 inovker
 is disable since 4.1.12 I believe if you do read the release note
 carefully
 in your tomcat installation.

 -Original Message-
 From: Lori Bishop [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, April 02, 2003 4:12 PM
 To: tomcat maillist
 Subject: Can't access my servlet


 I just installed Tomcat and am able to start it up successfully and
 access the examples servlet successfully using:
 http://localhost:8080/examples/servlet/HelloWorldExample

 I have my own servlet in

 C:\jakarta-tomcat-4.1.24\webapps\stcecilia\WEB-INF\classes\TestServlet.class
 When I try to access it with
 http://localhost:8080/stcecilia/servlet/TestServlet

 I get this message:
 description The requested resource (/stcecilia/servlet/TestServlet) is
 not available.

 Based on other postings in this mailing list, I added this entry to
 the server.xml

 !-- stcecilia Context --
  Context path=/stcecilia docBase=stcecilia debug=0
  reloadable=true crossContext=true
   Logger className=org.apache.catalina.logger.FileLogger
  prefix=localhost_stcecilia_log. suffix=.txt
timestamp=true/
   /Context


 Here is my C:\jakarta-tomcat-4.1.24\webapps\stcecilia\WEB-INF\web.xml

 ?xml version=1.0 encoding=ISO-8859-1?

 !DOCTYPE web-app
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
 http://java.sun.com/dtd/web-app_2_3.dtd;

 web-app

 display-nameStCeciliaSite/display-name
 description
   St Cecilia Website
 /description

 servlet
  servlet-nameTestServlet/servlet-name
  servlet-classTestServlet/servlet-class
 /servlet

 /web-app


 Any ideas on what I am doing wrong.  Thanks for your help,

 Lori


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



why has tomcat just crashed

2003-03-31 Thread JS
Hi All,
I recently began using the Java Web Services Devloper Pack (JWSDP)
installation of tomcat, which had been running fine up until now.I changed the 
server.xml file briefly to try and install a new context for
my app, but later replaced my changes with the original backup of the
server.xml file.
Now tomcat is refusing to start up, any idea why this is the case?

Heres the error

The requested URL could not be retrieved


While trying to retrieve the URL: http://localhost:8080/

The following error was encountered:

Unable to determine IP address from host name for localhost
The dnsserver returned:

Name Error: The domain name does not exist.
This means that:

 The cache was not able to resolve the hostname presented in the URL.
 Check if the address is correct.

Your cache administrator is webmaster.


Regards
JS



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



connection pooling saga

2003-03-31 Thread JS
Hello.
Has anyone ever done connection pooling with MS Access and tomcat 4.1.12?
I havent had much luck in trying to find this done anywhere, and much of
the advice is to go with mySQL. Though I am reluctant to due to the lack
of Foreign Key support in mySQL and the fact that I have done alot with
Access.
I have read the DBCP tomcat support docs, but this is only geared towards
mySQL, does such a thing exist for MS Access?
Advance thanks
JS



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: connection pooling saga

2003-03-31 Thread JS
Cheers Filip,
I didnt realise that DBCP would suppport Access.
(1) Doesnt the driver need to be a jar file though??

(2) I thought I needed an actual JDBC driver for MS Access.

(3) Does the DBCP support for MS Access Connection Pooling mean that I no
longer need my ConnectionPoolServlets to manage the connections.
I will read through the HOW-TOs again?
Any more advice would be much appreciated

JS


 who needs foreign keys, they only slow your DB down anyway :)

 DBCP can support any DB, you will need an ODBC bridge for Access, then
 you just give DBCP the odbc bridge driver info, and it should work

 Filip

 -Original Message-
 From: JS [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 31, 2003 4:06 PM
 To: [EMAIL PROTECTED]
 Subject: connection pooling saga


 Hello.
 Has anyone ever done connection pooling with MS Access and tomcat
 4.1.12? I havent had much luck in trying to find this done anywhere,
 and much of the advice is to go with mySQL. Though I am reluctant to
 due to the lack of Foreign Key support in mySQL and the fact that I
 have done alot with Access.
 I have read the DBCP tomcat support docs, but this is only geared
 towards mySQL, does such a thing exist for MS Access?
 Advance thanks
 JS



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED] For
 additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tomcat 4.01/Apache 1.13.22/Mod Webapp

2001-11-01 Thread JS

Okay I'm desparate.  I need help.  You guys have been great, but here's my 
deal:
I have set up Tomcat 4.01 to serve jsp alongside apache.  I'm trying to 
deploy an app that uses jdbc connections to mysql.  I know the connections 
work, but I am having a problem setting up server.xml and web.xml properly to 
stop the IllegalStateException errors my app keeps throwing once it connects 
through jdbc.  Any suggestions?

These are the error messages I get from the logs:
From catalina.out
StandardContext[/osc]: Mapping contextPath='/osc' with 
requestURI='/osc/template_designer/select_category.jsp' and 
relativeURI='/template_designer/select_category.jsp'
StandardContext[/osc]: Decoded 
relativeURI='/template_designer/select_category.jsp'
StandardContext[/osc]:   Trying exact match
StandardContext[/osc]:   Trying prefix match
StandardContext[/osc]:   Trying extension match
StandardContext[/osc]:  Mapped to servlet 'jsp' with servlet path 
'/template_designer/select_category.jsp' and path info 'null' and update=true
JspEngine -- /template_designer/select_category.jsp
 ServletPath: /template_designer/select_category.jsp
PathInfo: null
RealPath: 
/www/htdocs/webapps/osc/template_designer/select_category.jsp
  RequestURI: /osc/template_designer/select_category.jsp
 QueryString: null
  Request Params:
Classpath according to the Servlet Engine is: 
/www/htdocs/webapps/osc/WEB-INF/classes/:/www/htdocs/webapps/osc/WEB-INF/lib/mm.mysql-2.0.4-bin.jar:/www/htdocs/webapps/osc/WEB-INF/lib/mysql.jar:/a/www/tomcat/classes/:/a/www/tomcat/lib/jasper-runtime.jar:/a/www/tomcat/lib/naming-factory.jar:/a/www/tomcat/lib/jasper-compiler.jar:/a/www/tomcat/lib/mm.mysql-2.0.4-bin.jar:/a/www/tomcat/lib/mysql.jar:/a/www/tomcat/common/classes/:/a/www/tomcat/common/lib/mail.jar:/a/www/tomcat/common/lib/naming-common.jar:/a/www/tomcat/common/lib/jta-spec1_0_1.jar:/a/www/tomcat/common/lib/tyrex-0.9.7.0.jar:/a/www/tomcat/common/lib/xerces.jar:/a/www/tomcat/common/lib/activation.jar:/a/www/tomcat/common/lib/naming-resources.jar:/a/www/tomcat/common/lib/servlet.jar:/a/www/tomcat/common/lib/mm.mysql-2.0.4-bin.jar:/a/www/tomcat/common/lib/mysql.jar
Class name is: select_0005fcategory$jsp
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception




Also, the Scots are said to have invented golf.  Then they had
to invent Scotch whiskey to take away the pain and frustration.

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Tomcat 4.01/Apache 1.13.22/Mod Webapp

2001-11-01 Thread JS

PS I am clueless on this one guys.
-- 
Someone did a study of the three most-often-heard phrases in New York
City.  One is Hey, taxi.  Two is, What train do I take to get to
Bloomingdale's?  And three is, Don't worry.  It's just a flesh wound.
-- David Letterman

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Tomcat 4.01/Apache 1.13.22/Mod Webapp

2001-11-01 Thread JS

Maybe I should explain it a little better:
My Set up:
server.xml only has a service declared for apache mod_webapp. no stand alone.
apache has WebAppDeploy for the application
I want to be able to run the app from a directory under my apache doc root 
so I have my files under there /www/htdocs/webapp
for some reason, I think because of the way my xml files are configured, the 
app, apache, or tomcat (I don't know which) cannot access all of my class 
files.

On Thursday 01 November 2001 10:46, you wrote:
 JS at [EMAIL PROTECTED] wrote:
  Okay I'm desparate.  I need help.  You guys have been great, but here's
  my deal:
  I have set up Tomcat 4.01 to serve jsp alongside apache.  I'm trying to
  deploy an app that uses jdbc connections to mysql.  I know the
  connections work, but I am having a problem setting up server.xml and
  web.xml properly to stop the IllegalStateException errors my app keeps
  throwing once it connects through jdbc.  Any suggestions?

 It doesn't look like anything is weird with mod_webapp... IMO it's a JSP
 issue... Or does that stands out _only_ thru apache, while it works stand
 alone?

 Pier


 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]

-- 
I am, in point of fact, a particularly haughty and exclusive person, of
pre-Adamite ancestral descent.  You will understand this when I tell you
that I can trace my ancestry back to a protoplasmal primordial atomic
globule.  Consequently, my family pride is something inconceivable.  I
can't help it.  I was born sneering.
-- Pooh-Bah, The Mikado

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: how to use *.jsp w/ mod_webapp?

2001-10-18 Thread JS

These are the additions I've included in httpd.conf to make mod_webapp serve 
jsp:
LoadModule webapp_module libexec/mod_webapp.so

IfModule mod_webapp.c
WebAppConnection warpConnection warp localhost:8008
WebAppDeploy examples warpConnection /examples/
WebAppDeploy webdav warpConnection /webdav/
/IfModule

make sure the ServerName directive is uncommented.

Hope that helps.

On Thursday 18 October 2001 11:53, you wrote:
 Hi,
 I've built mod_webapp.so at last.

 When i was using mod_jk, my httpd.conf included:
  JkMount /*.jsp ajp12

 to enable JSP on apache.

 Now what shoud I rewrite that to?

 Using WebAppDeploy directive?
 If so, please give me an example.

 ---
 Truly Yours,
 Norihisa Washitake [EMAIL PROTECTED]

-- 
paak, n:A stadium or inclosed playing field. To put or leave (a
a vehicle) for a time in a certain location.
patato, n:  The starchy, edible tuber of a widely cultivated plant.
Septemba, n:The 9th month of the year.
shua, n:Having no doubt; certain.
sista, n:   A female having the same mother and father as the speaker.
tamato, n:  A fleshy, smooth-skinned reddish fruit eaten in salads
or as a vegetable.
troopa, n:  A state policeman.
Wista, n:   A city in central Masschewsetts.
yaad, n:A tract of ground adjacent to a building.
-- Massachewsetts Unabridged Dictionary