You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jakob Hummes <hu...@castify.net> on 2000/09/15 19:18:55 UTC
Java Color Model, Windows, Tomcat and Servlets
Hi,
we have developed some charting servlets and had a big surprise after
installing them on the server of our customer: The x- and y-axes weren't
visible anymore.
After some thoughts we tested the same code once again on our machines
(Windows 2000), but this time we set the resolution to standard VGA with
only 256 colors: Suprise again, the axes were gone. Setting it back to
true color gave the correct graphics.
Conclusion: Somehow the servlet rendered the chart with the resolution
of the server (I blame Java here) and produced (faulty?) 256 color
charts.
So my questions:
1) Is there a way, I can tell Tomcat/Java to use another resolution than
the resolution provided by the server (which typically even has no
graphic card)?
2) Do you know other tricks how to circumvent this problem?
Thanks,
- Jakob
Re: Java Color Model, Windows, Tomcat and Servlets
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Jakob Hummes wrote:
> Hi,
>
> we have developed some charting servlets and had a big surprise after
> installing them on the server of our customer: The x- and y-axes weren't
> visible anymore.
> After some thoughts we tested the same code once again on our machines
> (Windows 2000), but this time we set the resolution to standard VGA with
> only 256 colors: Suprise again, the axes were gone. Setting it back to
> true color gave the correct graphics.
>
> Conclusion: Somehow the servlet rendered the chart with the resolution
> of the server (I blame Java here) and produced (faulty?) 256 color
> charts.
>
> So my questions:
> 1) Is there a way, I can tell Tomcat/Java to use another resolution than
> the resolution provided by the server (which typically even has no
> graphic card)?
> 2) Do you know other tricks how to circumvent this problem?
>
Tomcat has absolutely nothing to do with how your graphics package works.
You'll need to go to the package supplier for solving this one.
>
> Thanks,
> - Jakob
Craig McClanahan
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat
Re: Java Color Model, Windows, Tomcat and Servlets
Posted by Alex Chaffee <gu...@edamame.stinky.com>.
See the jGuru Servlet FAQ for the answer:
"Is there any way to generate offscreen images without relying on the
native graphics support? I'd like to create an image without an X
server running."
http://www.jguru.com/jguru/faq/view.jsp?EID=121936
You are right to blame Java :-) but also blame Win2K for assuming all
your graphics will be at screen resolution. I once had to write a
servlet that generated images that had to run on a server with an
8-bit graphics card, so they always came out wrong. My solution was
to write the PureGraphics class (see FAQ) which does everything in
memory.
Cheers -
- Alex
On Fri, Sep 15, 2000 at 07:18:55PM +0200, Jakob Hummes wrote:
> Hi,
>
> we have developed some charting servlets and had a big surprise after
> installing them on the server of our customer: The x- and y-axes weren't
> visible anymore.
> After some thoughts we tested the same code once again on our machines
> (Windows 2000), but this time we set the resolution to standard VGA with
> only 256 colors: Suprise again, the axes were gone. Setting it back to
> true color gave the correct graphics.
>
> Conclusion: Somehow the servlet rendered the chart with the resolution
> of the server (I blame Java here) and produced (faulty?) 256 color
> charts.
>
> So my questions:
> 1) Is there a way, I can tell Tomcat/Java to use another resolution than
> the resolution provided by the server (which typically even has no
> graphic card)?
> 2) Do you know other tricks how to circumvent this problem?
>
> Thanks,
> - Jakob
--
Alex Chaffee mailto:alex@jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/
RE: Java Color Model, Windows, Tomcat and Servlets
Posted by Graeme Wallace <gr...@xxi.com>.
If you are using Java to render the charts then unless
you tell it otherwise you will be rendering into an image with
the default video settings on your machine.
If your video card on the server is shitty and only support 256 colors
then that is what you are going to get.
What you have to do is create an image of the correct depth and
draw into that. What Java version are you using 1.1.x or 1.2 and above ?
regards,
Graeme
-----Original Message-----
From: Jakob Hummes [mailto:hummes@castify.net]
Sent: Friday, September 15, 2000 12:19 PM
To: tomcat-user@jakarta.apache.org
Subject: Java Color Model, Windows, Tomcat and Servlets
Hi,
we have developed some charting servlets and had a big surprise after
installing them on the server of our customer: The x- and y-axes weren't
visible anymore.
After some thoughts we tested the same code once again on our machines
(Windows 2000), but this time we set the resolution to standard VGA with
only 256 colors: Suprise again, the axes were gone. Setting it back to
true color gave the correct graphics.
Conclusion: Somehow the servlet rendered the chart with the resolution
of the server (I blame Java here) and produced (faulty?) 256 color
charts.
So my questions:
1) Is there a way, I can tell Tomcat/Java to use another resolution than
the resolution provided by the server (which typically even has no
graphic card)?
2) Do you know other tricks how to circumvent this problem?
Thanks,
- Jakob
RE: mod_jk vs. mod_jserv
Posted by Mike Bremford <mi...@paperx.com>.
I believe it's also supposed to differentiate between HTTP and HTTPS
correctly.
I haven't looked at the mod_jk source, but I know that the jserv protocol
as it stands can't identify an SSL connection to tomcat. Apache/JServ got
around this with a hack (if the connection was on port 443, it's secure),
but
tomcat hasn't done this, which is why the scheme is always HTTP and
isSecure()
always returns false if you connect via mod_jserv.
Cheers... Mike
> -----Original Message-----
> From: Thomas T. Veldhouse [mailto:veldy@veldy.net]
> Sent: 18 September 2000 18:31
> To: tomcat-user@jakarta.apache.org; Daniel.Barclay@digitalfocus.com
> Subject: Re: mod_jk vs. mod_jserv
>
>
> It seems to me that this modules will not instantiate a
> separate instance of
> the Java interpreter, as mod_jserv does. Thus you save on
> resources. I
> assume that for this very reason, it is probably faster as well.
>
> Tom Veldhouse
> veldy@veldy.net
>
> ----- Original Message -----
> From: Daniel Barclay <Da...@digitalfocus.com>
> To: <to...@jakarta.apache.org>
> Sent: Monday, September 18, 2000 12:02 PM
> Subject: mod_jk vs. mod_jserv
>
>
> >
> > Is there any advantage to using mod_jk instead of mod_jserv (with
> > Apache)? More specifically, is there any need to use mod_jk (e.g.,
> > to get exclusive features) instead of mod_jserv?
> >
> > The "Working with mod_jk" (at
> >
> http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/mod_jk
-howto.html)
> doesn't seem to say anything about that.
>
> Thanks,
>
> Daniel
> --
> Daniel Barclay
> Digital Focus
> Daniel.Barclay@digitalfocus.com
>
Re: mod_jk vs. mod_jserv
Posted by "Thomas T. Veldhouse" <ve...@veldy.net>.
It seems to me that this modules will not instantiate a separate instance of
the Java interpreter, as mod_jserv does. Thus you save on resources. I
assume that for this very reason, it is probably faster as well.
Tom Veldhouse
veldy@veldy.net
----- Original Message -----
From: Daniel Barclay <Da...@digitalfocus.com>
To: <to...@jakarta.apache.org>
Sent: Monday, September 18, 2000 12:02 PM
Subject: mod_jk vs. mod_jserv
>
> Is there any advantage to using mod_jk instead of mod_jserv (with
> Apache)? More specifically, is there any need to use mod_jk (e.g.,
> to get exclusive features) instead of mod_jserv?
>
> The "Working with mod_jk" (at
> http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/mod_jk-howto.html)
> doesn't seem to say anything about that.
>
> Thanks,
>
> Daniel
> --
> Daniel Barclay
> Digital Focus
> Daniel.Barclay@digitalfocus.com
>
handling .jsp files in Apache user directories
Posted by Daniel Barclay <Da...@digitalfocus.com>.
Is this a FAQ that is already answered somewhere?:
Can TomCat 3.1 serve as an Apache handler for .jsp files that are contained
within the regular content directories, specifically including user direc-
tories (e.g., "http://server/~username")?
I've figured out a (crude) way to set up TomCat to handle .jsp files
under Apache's document root directory.
(In server.xml, I used '<Context path="" docbase="/path/to/Apache/htdocs" ...>'
to have TomCat look for .jsp files in the same directories from which Apache is
serving out regular files.
That is, just as the URL http://localhost/f normally maps to file .../htdocs/f,
the URL http://localhost/f.jsp maps to file .../htdocs/f.jsp (instead of a file
f.jsp in a completely separate directory).)
However, that of course doesn't work for .jsp files in user directories.
(Tomcat reports the error:
"/path/to/Apache/htdocs/~someuser/test.jsp" not found
.)
Is there a way for TomCat to look for files relative to the directory
("/home/username/public_html") usually associated with the URL instead of
relative to the original URL (".../~username")?
Thanks,
Daniel
--
Daniel Barclay
Digital Focus
Daniel.Barclay@digitalfocus.com
mod_jk vs. mod_jserv
Posted by Daniel Barclay <Da...@digitalfocus.com>.
Is there any advantage to using mod_jk instead of mod_jserv (with
Apache)? More specifically, is there any need to use mod_jk (e.g.,
to get exclusive features) instead of mod_jserv?
The "Working with mod_jk" (at
http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/mod_jk-howto.html)
doesn't seem to say anything about that.
Thanks,
Daniel
--
Daniel Barclay
Digital Focus
Daniel.Barclay@digitalfocus.com
Re: Still Problems with Servlets and MySQL - JDBC
Posted by Kevin Sangeelee <ke...@susa.net>.
We had this one a while back and from what I recall there is a parameter
in mysqld that specifies a connection timeout. After this period of time
elapses, the server thread will close down, breaking the connection, and a
new thread will be created. It does this to reduce the chances of resource
wind ups etc.
Two solutions suggested were to (1) change the mysqld timeout and/or (2)
use a connection pooling class that verifies a connection before handing
it to you, re-connecting where necessary.
In my opinion, it's not a good idea to create connections in init()
because lots of things can happen after this call.
Kevin Sangeelee
p.s. Open Source JSP tree control (CSTreeBean-0.3) at
http://www.coolservlets.com
On Mon, 18 Sep 2000, Stefan Urban wrote:
> I still have a very big Problem with Servlets and MySQL - JDBC.
> The code is not a hack. Just a very usally way to get the Database
> Connection. I still got the Problem, that when my Servlets run for a while
> I don't get any Data from the Connection. I mean for a while everything
> went well and some times later it won't work. I even get no error messages
> in some of the known Log-Files!!! I even tried the same Code with JServ
> (latest Version) and it works. You find the Code below. If I get any help
> and any solutions I will use Tomcat (and I want to). Otherwise I have to
> install the JServ Mod.
Still Problems with Servlets and MySQL - JDBC
Posted by Stefan Urban <su...@pevo.de>.
Hi,
I still have a very big Problem with Servlets and MySQL - JDBC.
The code is not a hack. Just a very usally way to get the Database
Connection. I still got the Problem, that when my Servlets run for a while
I don't get any Data from the Connection. I mean for a while everything
went well and some times later it won't work. I even get no error messages
in some of the known Log-Files!!! I even tried the same Code with JServ
(latest Version) and it works. You find the Code below. If I get any help
and any solutions I will use Tomcat (and I want to). Otherwise I have to
install the JServ Mod.
Thanx for any help. Best regards.
-Stefan
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import servapletcom.*;
import navigation.*;
import tabsite1.*;
public class TaxiServlet extends HttpServlet {
protected Connection dbCon;
public void init() throws ServletException {
dbCon = null;
String strDBDriver = getInitParameter("JDBC_DRIVER");
String strDBConn = getInitParameter("DATABASE_CONNECTION");
try {
Class.forName(strDBDriver);
dbCon = DriverManager.getConnection(strDBConn);
}
catch (Exception e) {
System.err.println("Databaseconnection failed (init)");
System.err.println(strDBDriver);
System.err.println(strDBConn);
System.err.println(e.toString());
return;
}
}
public void destroy() {
if (dbCon != null)
{
try {
dbCon.close();
dbCon = null;
}
catch (Exception e) {
System.err.println("Database close failed: " + e.toString());
}
}
}
public void service (HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
if (dbCon == null)
{
String strDBDriver = getInitParameter("JDBC_DRIVER");
String strDBConn = getInitParameter("DATABASE_CONNECTION");
try {
Class.forName(strDBDriver);
dbCon = DriverManager.getConnection(strDBConn);
}
catch (Exception e) {
System.err.println("Databaseconnection failed (init)");
System.err.println(strDBDriver);
System.err.println(strDBConn);
System.err.println(e.toString());
return;
}
}
String strRS = request.getParameter("rs");
String strWhich = request.getParameter("which");
if (strWhich.compareTo("__TAXI__REFRESH") == 0) {
refresh( request, response);
}
if (strWhich.compareTo("__TAXI__UPDATE") == 0) {
save(strRS, response);
}
if (strWhich.compareTo("__TAXI__DELETE") == 0) {
delete(strRS, response);
}
if (strWhich.compareTo("__TAXI__INSERT") == 0) {
create(strRS, response);
}
}
protected void refresh(HttpServletRequest request, HttpServletResponse
response)
{
try {
Statement sQuery = dbCon.createStatement();
ResultSet rsAdressen = sQuery.executeQuery("SELECT * FROM adressen");
String sOutput = new String();
ArtikelDataClass adcTmp = new ArtikelDataClass();
while (rsAdressen.next()) {
... not interesting
}
sQuery.close();
PrintWriter out = new PrintWriter (response.getOutputStream());
response.setContentType("text/html");
out.println(sOutput);
out.close();
} catch (SQLException e) {
System.out.println(e.toString());
}
catch (IOException e) {
System.out.println(e.toString());
}
}
protected void save(String strRS, HttpServletResponse response)
{
....
}
protected void delete(String strRS, HttpServletResponse response)
{
...
}
protected void create(String strRS, HttpServletResponse response)
{
....
}
}
Re: Java Color Model, Windows, Tomcat and Servlets
Posted by Kevin Sangeelee <ke...@susa.net>.
I don't know about under Windoze, but Unix solutions can use Xvfb which is
a virtual X server that you can define to provide many virtual
framebuffers at differing width x height x depths. You can then use the
standard AWT stuff to render graphics in the virtual buffer.
I understand that there are other solutions beside Xvfb. I got this answer
a while back from the KavaCharts people.
On Fri, 15 Sep 2000, Jakob Hummes wrote:
> So my questions:
> 1) Is there a way, I can tell Tomcat/Java to use another resolution than
> the resolution provided by the server (which typically even has no
> graphic card)?
> 2) Do you know other tricks how to circumvent this problem?