hi jeff ,hi all,
the servlet you use is a servlet 2.3 stuff, i think.
is there any url to take a look at this code?
i am involved in creating svg's and not very familar with writing servlets.
but i'd like to show my interactive work.
i tried this ( i found in german java-magazin 04/2001):
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.batik.transcoder.*;
import org.xml.sax.*;
import java.io.*;
public class BatikFilter implements Filter{
private FilterConfig config = null;
private String format = "jpeg";
public BatikFilter() {
}
public void doFilter(ServletRequest parm1, ServletResponse parm2,
FilterChain parm3) throws java.io.IOException,
javax.servlet.ServletException {
SpoofResponse spoof = new SpoofResponse();
parm3.doFilter(parm1, spoof);
String uri = "";
if (parm1 instanceof HttpServletRequest)
{
HttpServletRequest httpReq = (HttpServletRequest) parm1;
uri = httpReq.getRequestURI().toString();
}
String localFormat = (String) parm1.getParameter("format");
if (localFormat != null) format = localFormat;
try
{
String ctype = parm1.getContentType();
if ((ctype == null) | ((ctype != null) && (ctype.indexOf("svg")
!= -1)))
{
Class transcoderClass = (Class) handlers.get(format);
if (transcoderClass == null) return;
Transcoder trans = (Transcoder) transcoderClass.newInstance();
trans.addTranscodingHint(org.apache.batik.transcoder.XMLAbstractTranscoder.K
EY_XML_PARSER_CLASSNAME,
"org.xml.sax.XMLReader");
ByteArrayOutputStream os = new ByteArrayOutputStream();
TranscoderInput tip = new TranscoderInput (new InputStreamReader
(new ByteArrayInputStream (spoof.getBuffer())));
tip.setURI(uri);
TranscoderOutput top;
if (format.equals ("svg"))
{
top = new TranscoderOutput (new OutputStreamWriter (os));
}
else
{
top = new TranscoderOutput (os);
}
trans.transcode(tip, top);
byte[] buffer = os.toByteArray();
parm2.setContentType((String) mimetypes.get(format));
parm2.getOutputStream().write(buffer);
}
else
{
String result = "<html><body>Content filtered!</body></html>";
parm2.setContentType("text/html");
parm2.reset();
parm2.getWriter().print(result);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public FilterConfig getFilterConfig() {
return config;
}
public void setFilterConfig(FilterConfig parm1) {
config = parm1;
}
private static Map handlers = new HashMap();
private static Map mimetypes = new HashMap();
{
handlers.put ("jpeg",
org.apache.batik.transcoder.image.JPEGTranscoder.class);
handlers.put ("png",
org.apache.batik.transcoder.image.PNGTranscoder.class);
handlers.put ("svg",
org.apache.batik.transcoder.svg2svg.SVGTranscoder.class);
mimetypes.put ("jpeg", "image/jpeg");
mimetypes.put ("png", "image/png");
mimetypes.put ("svg", "image/svg+xml");
}
}
class SpoofResponse extends ResponseBase { }
but sax isn't instanciated correctly( no empty public constructor)
any idea that makes me happy?
thanks
stefan
----- Original Message -----
From: "Noll, Jeff HS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 27, 2001 5:15 PM
Subject: RE: chart in jsp
With a little bit of effort, you can make some pretty impressive completely
dynamic graphs using SVG. I actually use a servlet for this that transforms
XML data from oracle into SVG. Then I use a <jsp:include> to get the graph
into the jsp page. Of course, the one caveat is that it requires an SVG
plugin to view the graph, but once you have it its a great tool.
I've got it set up so that once the query to get the XML out of Oracle is
written, I can do bar, pie, and line graphs complete with drill down views
of just about any data. The real work is in the XSL stylesheet you create,
which definately isn't a trivial task.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 27, 2001 12:21 AM
To: [EMAIL PROTECTED]
Subject: Re: chart in jsp
The only dynamic charts I've seen have used fixed size images combined
dynamically to form a graph, chart, tree, etc.
sorry, no code.
Neill Laney
http://home.nc.rr.com/nlaney
--
Web Developer/Technical Support Specialist.
Altuğ
Altıntaş To:
"'[EMAIL PROTECTED]'"
(Koç.Net) <[EMAIL PROTECTED]>
<[EMAIL PROTECTED] cc:
et> Subject: chart in jsp
03/26/2001
05:24 AM
Please
respond to
tomcat-user
are there any way to draw a dynamic chart in jsp ?
any source or idea ?
thanks ..