You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by javaNoob <no...@yahoo.com> on 2007/07/02 12:46:11 UTC
load & save using servlet
how do i load and save svg in servlet? please help. i'm new to this
technology. thank you
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11391797
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
when i first open netbeans and run the webapp i am doing i get an error..
java.lang.NullPointerException
at org.apache.batik.dom.util.DOMUtilities.writeDocument(Unknown
Source)
at map.LoadMapServlet.svgToString(LoadMapServlet.java:40)
at map.LoadMapServlet.processRequest(LoadMapServlet.java:129)
at map.LoadMapServlet.doGet(LoadMapServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
this error only shows when i open netbeans and run the webapp for the first
time.. if i recompile, it does not show..
this is the method where i get the error
protected String svgToString(SVGDocument doc) {
//Outputs the contents of the entire current DOM as a single string
StringWriter writer;
String svg = null;
try{
writer = new StringWriter();
DOMUtilities.writeDocument(doc, writer); ----->this is where the
error is
writer.close();
svg = writer.toString();
}
catch (IOException e) {
e.printStackTrace();
}
return svg;
}
i can;t understand what the error means.. the SVGDocument is not null
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11560634
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
Read here:
http://xmlgraphics.apache.org/batik/using/transcoder.html
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Monday, July 02, 2007 9:58 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: load & save using servlet
anyone please. just the classes to use in loading and saving.
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11395456
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
ok.. thanks!
Paul L. Bogen wrote:
>
> Try this method:
> http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SAX
> SVGDocumentFactory.html#createSVGDocument(java.lang.String,%20java.io.In
> putStream)
>
> -----Original Message-----
> From: javaNoob [mailto:noypi_baller@yahoo.com]
> Sent: Tuesday, July 10, 2007 11:50 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: RE: load & save using servlet
>
>
> i converted it to string so that i can serialize it and pass it to an
> applet.. is it possible to make it a SVGDoucment using this method?
> --
> View this message in context:
> http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524835
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11525034
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
i do not exactly know how to use the createSVGDocument(String uri,
InputStream inp). is the uri the location of the svg file? how do i use
thise in an applet? please help me..
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11533284
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
Try this method:
http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SAX
SVGDocumentFactory.html#createSVGDocument(java.lang.String,%20java.io.In
putStream)
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Tuesday, July 10, 2007 11:50 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: load & save using servlet
i converted it to string so that i can serialize it and pass it to an
applet.. is it possible to make it a SVGDoucment using this method?
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524835
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
i converted it to string so that i can serialize it and pass it to an
applet.. is it possible to make it a SVGDoucment using this method?
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524835
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
This is how I load an SVG
URI uri = new URI("[SOME URI]");
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory sax = new SAXSVGDocumentFactory(parser);
SVGDocument doc = sax.createSVGDocument(uri.toString());
plb
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Tuesday, July 10, 2007 11:43 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: load & save using servlet
ok.. i think i missed something.. i converted the string to a document
and then applied a SVGDocument type-cast to it.. is it automatically a
SVGDocument? i am getting an error when i call doc.getRootElement()
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524620
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
ok.. i think i missed something.. i converted the string to a document and
then applied a SVGDocument type-cast to it.. is it automatically a
SVGDocument? i am getting an error when i call doc.getRootElement()
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524620
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
that's what i did.. it does not display anything.. if the svg has comments,
will it work?
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524601
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
SVGCanvas.setSVGDocument( document );
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Tuesday, July 10, 2007 11:31 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: load & save using servlet
edit it with a Swing application...
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524478
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
edit it with a Swing application...
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11524478
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
Do you mean edit it with a Swing application or modify the DOM?
If you just want to do DOM manipulation you don't need SVGCanvas.
plb
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Tuesday, July 10, 2007 10:55 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: load & save using servlet
i loaded a svg from the server and converted it to string to send to an
applet. after applet receives the string, it converts the string to a
SVGDocument (using code from here:
http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200412.
mbox/%3CBAY102-F21CE252746BD00AD6EA1EFCDAB0@phx.gbl%3E)..
i want to edit this document.. how do i add the SVGDocument to the
SVGCanvas and edit it?
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11523783
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
i loaded a svg from the server and converted it to string to send to an
applet. after applet receives the string, it converts the string to a
SVGDocument (using code from here:
http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200412.mbox/%3CBAY102-F21CE252746BD00AD6EA1EFCDAB0@phx.gbl%3E)..
i want to edit this document.. how do i add the SVGDocument to the SVGCanvas
and edit it?
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11523783
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
any suggestions?
another question.. what is the difference between this:
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
String uri = "http://localhost:8084/MyWebApp/mapSpain.svg";
Document doc = f.createDocument(uri);
and this:
String uri = "http://localhost:8084/CityNavigator/mapSpain.svg";
UserAgentAdapter ua = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(ua);
Document doc = loader.loadDocument(uri);
i still want to load the svg file from the server... sorry for asking many
questions.. i am trying hard not to ask but i still do not get a lot of
things
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11439541
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
so i have this code.. do i pass the doc object or there is a more efficient
way?
package myPackage;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Document;
public class LoadMapServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
String uri = "http://localhost:8084/MyWebApp/mapSpain.svg";
Document doc = f.createDocument(uri);
} catch (IOException ex) {
ex.printStackTrace();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
}
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11431791
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
ok.. i did a lot of trial and error and it finally worked.. sorry
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11425278
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
here is my servlet code:
package map;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Document;
public class LoadMapServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
String uri = "http://localhost:8084/MyWebApp/mapSpain.svg";
Document doc = f.createDocument(uri);
System.out.println(doc);
} catch (IOException ex) {
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
}
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11424914
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
i have a servlet and used the code given for testing but i am doing something
wrong. i put the batik-dom.jar, batik-svg-dom.jar, and batik-util.jar in my
WEB-INF folder but i still get the error
exception
javax.servlet.ServletException: Wrapper cannot find servlet class
map.LoadMapServlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.ClassNotFoundException: map.LoadMapServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
am i missing something in the jars?
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11424876
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: load & save using servlet
Posted by "Paul L. Bogen" <pl...@kbsi.com>.
Correction, I think this is more of what you want:
http://xmlgraphics.apache.org/batik/using/dom-api.html
-----Original Message-----
From: javaNoob [mailto:noypi_baller@yahoo.com]
Sent: Monday, July 02, 2007 9:58 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: load & save using servlet
anyone please. just the classes to use in loading and saving.
--
View this message in context:
http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11395456
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: load & save using servlet
Posted by javaNoob <no...@yahoo.com>.
anyone please. just the classes to use in loading and saving.
--
View this message in context: http://www.nabble.com/load---save-using-servlet-tf4011429.html#a11395456
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org