How to declare Output as Image?

2001-09-07 Thread Andrej Rosenheinrich

Hello,

i have a servlet, getting an BufferedImage, that shall be displayed in 
my webpage. for doing this I use the following code:

ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image);

(image is the Buffered Image)
Well, the servlet does something, the title-line even claims that there 
is a graphic of  a certain size (the right one, btw ;-)), but in the 
page is only the url of the servlet :-(
I guess, I somehow have to tell the servlet/outputstream??? that the 
upcoming data is an image. right? how can i do this in a servlet? any hints?

TIA
Andrej




Tomcat doesnt recognize new context

2001-08-28 Thread Andrej Rosenheinrich

Hi,

as I posted last night, I added several new contexts, but Tomcat doesnt 
recognize it. I am quite sure that this is the problem, checking 
logfiles Tomcat newer initiated any servlet in one of the contexts I 
added. Here is my server.xml - file:

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

Server
!-- Debug low-level events in XmlMapper startup --
xmlmapper:debug level=0 /

!--

Logging:

 Logging in Tomcat is quite flexible; we can either have a log
 file per module (example: ContextManager) or we can have one
 for Servlets and one for Jasper, or we can just have one
 tomcat.log for both Servlet and Jasper.  Right now there are
 three standard log streams, tc_log, servlet_log, and
 JASPER_LOG. 

 Path:

 The file to which to output this log, relative to
 TOMCAT_HOME.  If you omit a path value, then stderr or
 stdout will be used.

 Verbosity:

 Threshold for which types of messages are displayed in the
 log.  Levels are inclusive; that is, WARNING level displays
 any log message marked as warning, error, or fatal.  Default
 level is WARNING.

 verbosityLevel values can be:
FATAL
ERROR
WARNING
INFORMATION
DEBUG

 Timestamps:

 By default, logs print a timestamp in the form -MM-dd
 hh:mm:ss in front of each message.  To disable timestamps
 completely, set 'timestamp=no'. To use the raw
 msec-since-epoch, which is more efficient, set
 'timestampFormat=msec'.  If you want a custom format, you
 can use 'timestampFormat=hh:mm:ss' following the syntax of
 java.text.SimpleDateFormat (see Javadoc API).  For a
 production environment, we recommend turning timestamps off,
 or setting the format to msec.

 Custom Output:

 Custom means normal looking.  Non-custom means
 surrounded with funny xml tags.  In preparation for
 possibly disposing of custom altogether, now the default is
 'custom=yes' (i.e. no tags)

 Per-component Debugging:

 Some components accept a debug attribute.  This further
 enhances log output.  If you set the debug level for a
 component, it may output extra debugging information.
--

!-- if you don't want messages on screen, add the attribute
path=logs/tomcat.log
 to the Logger element below
--
Logger name=tc_log
verbosityLevel = INFORMATION
/

Logger name=servlet_log
path=logs/servlet.log
/

Logger name=JASPER_LOG
path=logs/jasper.log
verbosityLevel = INFORMATION /

!-- You can add a home attribute to represent the base for
 all relative paths. If none is set, the TOMCAT_HOME property
 will be used, and if not set . will be used.
 webapps/, work/ and logs/ will be relative to this ( unless
 set explicitely to absolute paths ).

 You can also specify a randomClass attribute, which determines
 a subclass of java.util.Random will be used for generating 
session IDs.
 By default this is java.security.SecureRandom.
 Specifying java.util.Random will speed up Tomcat startup,
 but it will cause sessions to be less secure.

 You can specify the showDebugInfo attribute to control whether
 debugging information is displayed in Tomcat's default responses.
 This debugging information includes:
 1. Stack traces for exceptions
 2. Request URI's that cause status codes = 400
 The default is true, so you must specify false to prevent
 the debug information from appearing.  Since the debugging
 information reveals internal details about what Tomcat is serving,
 set showDebugInfo=false if you wish increased security.
  --
ContextManager debug=0 workDir=work showDebugInfo=true 

  !--  Interceptors  --

!--
 ContextInterceptor className=org.apache.tomcat.context.LogEvents
 --
   
ContextInterceptor 
className=org.apache.tomcat.context.AutoSetup /

ContextInterceptor
className=org.apache.tomcat.context.WebXmlReader /

!-- Uncomment out if you have JDK1.2 and want to use policy
ContextInterceptor
className=org.apache.tomcat.context.PolicyInterceptor /
--

ContextInterceptor
className=org.apache.tomcat.context.LoaderInterceptor /
ContextInterceptor
className=org.apache.tomcat.context.DefaultCMSetter /
ContextInterceptor
className=org.apache.tomcat.context.WorkDirInterceptor /

!-- Request processing --
!-- Session interceptor will extract the session id from 
cookies and
 deal with URL rewriting ( by fixing the URL ).  If you wish to
 suppress the use of cookies for session identifiers, change the
 

OutOfMEmory?

2001-08-27 Thread Andrej Rosenheinrich

Hello,

I took the sampleprogram from the last JDC-Techtips newsletter, and 
wrote a servlet that reads a tiff-file and gives out the result 
(jpg-image) in a webpage. trying this with more than a tiny example 
(100x100 pixels) I am getting an OutOfMemory message. The tiff-file is 
27KB large, using the method for converting on the commandline I am 
getting an 220KB image (jpeg) (conerting works propely). I dont really 
believe that this is a memory problem. What else can cause this 
errormessage? What limits and quotas would you recommend for tomcat? 
Where can I change those limits or quotas? I am using tomcat 3.2.1 under 
OpenVMS.

Thanks for any help!
Andrej




NullPointer Exception in AdaptiveClassLoader

2001-08-27 Thread Andrej Rosenheinrich

Hello,

I tried to add a new context (by using the admin page coming with tomcat 
and checking the results in server.xml by hand), wrote a servlet, put it 
in web-inf/classes (compiled of course ;-)), did the mapping in web.xml 
and wanted to test it. The result was a NullPointer Exception at 
AdaptiveClassLoader.loadClass
Looks to me like tomcat cant find the context. Searching the maillist, 
this aint the first question to such an error. Still, the cause for this 
error isnt clear to me or what the solution is. Any ideas?

Thanks
Andrej





File not readable

2001-08-16 Thread Andrej Rosenheinrich


Hello,

I would really need some help on a problem thats probably pretty simple
but I have absolutely no clue why this happens.

I am running Tomcat on OpenVMS. I wrote a java-class that reads a
graphicfile, converts it and writes the outputfile on disk. Running this
from commandline it works properly. The problem starts when trying to use
this method from an servlet. Already the attempt to read the inputfile
fails with the error-message: file not readable. 
I set the permission in tomcat.policy for the whole directory to
read+write+delete, so I think it aint a security-problem. If it would 
be a problem with permissions I also should get a SecurityException
instead. Apart from that I tested the file with some methods of the
File-class. The file exists, is a normal file, but just not readable ...

Any ideas anyone? Thanks for any hint!

Andrej Rosenheinrich

---
I lived a thousand times, I found out what it means to be believed
Black Sabbath

email : [EMAIL PROTECTED]





Re: File not readable

2001-08-16 Thread Andrej Rosenheinrich

Hi Rob,

yes, File not readable is a Exception. Here is what i get by trying to
read from the file:

Error: 500
Location: /aba2/show_proof
Internal Servlet Error:

java.lang.IllegalArgumentException:
APACHE$DISK:[APACHE.JAKARTA.WEBAPPS.aba2]00EB.TIF: File is not
readable.
at javax.media.jai.JAI.createNS  (JAI.java:906)  (pc 252)
at
javax.media.jai.JAI.create(java.lang.String,java.awt.image.renderable.ParameterBlock,java.awt.RenderingHints)
(JAI.java:786) (pc 6)
at
javax.media.jai.JAI.create(java.lang.String,java.awt.image.renderable.ParameterBlock)
(JAI.java:1210) (pc 3)
at ToJPEG.loadImage  (ToJPEG.java:32)(pc 15)
at ToJPEG. (ToJPEG.java:89)(pc 44)
at ShowProof.doPost  (ShowProof.java:113)(pc 345)
at
javax.servlet.http.HttpServlet.service(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
(HttpServlet.java:760) (pc 139)
at
javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest,javax.servlet.ServletResponse)
(HttpServlet.java:853) (pc 29)
at org.apache.tomcat.core.ServletWrapper.doService
(ServletWrapper.java:404) (pc 62)
at org.apache.tomcat.core.Handler.service (Handler.java:286) (pc
194)
at org.apache.tomcat.core.ServletWrapper.service
(ServletWrapper.java:372) (pc 140)
at org.apache.tomcat.core.ContextManager.internalService
(ContextManager.java:797) (pc 250)
at org.apache.tomcat.core.ContextManager.service
(ContextManager.java:743) (pc 3)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection
(HttpConnectionHandler.java:210) (pc 388)
at org.apache.tomcat.service.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:416) (pc 73)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run
(ThreadPool.java:498) (pc 132)
at java.lang.Thread.run  (Thread.java:484)   (pc 11)#



As I mentioned, the file exists, i can use my method from the commandline,
I gave (hopefully right ;-)) full acces to the directory. But trying to
read from that file with a servlet ... no way!

Hope this helps

Andrej



On Thu, 16 Aug 2001, Rob S. wrote:

 Hi Andrej,
 
 I'm really going to need more information.  Can you paste the stack trace?  Telling 
me file not readable i have no idea what that means.  Is that a trap by your code?  
An exception of some sort?
 
 - r
 
 On Thu, 16 Aug 2001 18:31:42 +0200 (MET DST) [EMAIL PROTECTED] wrote:
  
  Hello,
  
  I would really need some help on a problem thats probably pretty simple
  but I have absolutely no clue why this happens.
  
  I am running Tomcat on OpenVMS. I wrote a java-class that reads a
  graphicfile, converts it and writes the outputfile on disk. Running this
  from commandline it works properly. The problem starts when trying to use
  this method from an servlet. Already the attempt to read the inputfile
  fails with the error-message: file not readable.
  I set the permission in tomcat.policy for the whole directory to
  read+write+delete, so I think it aint a security-problem. If it would
  be a problem with permissions I also should get a SecurityException
  instead. Apart from that I tested the file with some methods of the
  File-class. The file exists, is a normal file, but just not readable ...
  
  Any ideas anyone? Thanks for any hint!
  
  Andrej Rosenheinrich
  
  
  ---
  I lived a thousand times, I found out what it means to be believed
  Black Sabbath
  
  email : [EMAIL PROTECTED]
 
 
 
 

Andrej Rosenheinrich

---
I lived a thousand times, I found out what it means to be believed
Black Sabbath

email : [EMAIL PROTECTED]
http  : www.minet.uni-jena.de/~aros
Tel   : (+49) 0177/8743619
(+49) 03641/448695




Re: File not readable (fwd)

2001-08-16 Thread Andrej Rosenheinrich

Well,

this aint it. I resolved the variables using RealPath, checked the
resolved filename, same result. Here is a fast test i tried:

/* test File
   try
   {
  File inputfile = new
File(APACHE$DISK:[APACHE.JAKARTA.WEBAPPS.aba2]00EB.tif);
  try 
  {
 if (inputfile.isFile())
 {
out.println(File is a normal file ...BR);
 }
 else
 {
out.println(File is NOT a normal file ...BR);
 }
  }
  catch (SecurityException exp)
  {
 out.println(Securitymanager denies access to
file!!!);
  }
  try
  {
 if (inputfile.canRead())
 {
out.println(File is readable ...);
 }
 else
 {
out.println(File is NOT readable ...);
 }
  }
  catch (SecurityException exp)
  {
 out.println(Securitymanager denies access to
file!!!);
  }
   }
   catch (NullPointerException exp)
   {
  out.println(Filename ist null ...);
   }
*/ //End Test File

the file exists, it's a normal file, but I cant read it. I dont think it's
a thing with permissions, cause then I should get a SecurityException
trying to access it ...


Andrej



On Thu, 16 Aug 2001, Rob S. wrote:

  java.lang.IllegalArgumentException:
  APACHE$DISK:[APACHE.JAKARTA.WEBAPPS.aba2]00EB.TIF: File is not
  readable.
 
 I have no idea what javax.media is, but it looks like you're trying to use
 environment variables from inside a web app. On the command-line, they will
 be resolved and the right values put in to Java. In a web app, since there is
 no shell to resolve them, they are taken literally.
 
 - r
 
 

Andrej Rosenheinrich

---
I lived a thousand times, I found out what it means to be believed
Black Sabbath

email : [EMAIL PROTECTED]
http  : www.minet.uni-jena.de/~aros
Tel   : (+49) 0177/8743619
(+49) 03641/448695