Solved

java servlet & creating wbmp images

Posted on 2000-04-02
6
266 Views
Last Modified: 2013-11-24
Hi all!!

I don't know if someone knows the "WBMPcreator". - It is a Java bean for creating WBMP images (=images for wap-devices) automatically and can be found at http://www.netcity.ru/~mkrainov/.


My problem is that it seems that I can't use it together with java-servlets!


* I've took the WBMPcreator-example from
http://www.netcity.ru/~mkrainov/1.05/WBMPStarter.java => that works
* when I create an WBMPfile somewhere in a servlet I get some
"BufferedImage" - Error!!!

=> could someone give me a hint how to make that work???? - And how do I write the WBMP-file into the outputstream??? - with "out.println(file);"
???


thanks!
klaus oberecker


----------
/*
http://www.netcity.ru/~mkrainov/1.05/WBMPStarter.java
... works fine ...
*/
import java.awt.*;
import WBMPcreator.WBMPfile;

public class WBMPStarter {
  private WBMPfile file1;

  public WBMPStarter(){
    Font outFont=new Font("Courier",Font.BOLD,15);
    file1 = new WBMPfile(96,15);
    file1.drawString(" USDJPY",1,11,outFont);
    file1.drawLine(0,0,96,0);
    file1.drawRect(1,1,92,11,false);
    file1.saveWBMP2File("test3.wbmp");
  } // WBMPStarter constructor

  public static void main(String[] args) {
    WBMPStarter wBMPStarter = new WBMPStarter();
  } // main
} // WBMPStarter class

/*

... but placed somewhere in a servlet produces errors:

------ servlet doGet method: ---------
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
        res.setHeader("Pragma", "no-cache");
        res.setHeader("Cache-Control", "no-cache");
        res.setDateHeader("Expires", 0);

        res.setContentType("image/vnd.wap.wbmp");
        out=res.getWriter();

    Font outFont=new Font("Courier",Font.BOLD,15);
    file1 = new WBMPfile(96,15);
    file1.drawString(" USDJPY",1,11,outFont);
    file1.drawLine(0,0,96,0);
    file1.drawRect(1,1,92,11,false);
//    file1.saveWBMP2File("test3.wbmp");

        out.println(file1.toString());
        out.close();
}


---- error message ----
reported this exception: java/awt/image/BufferedImage. Please report
this to the administrator of the web server.

     java.lang.NoClassDefFoundError: java/awt/image/BufferedImage at
     WBMPcreator.WBMPfile.prepareRaster(WBMPfile.java:441) at
     WBMPcreator.WBMPfile.text2WBMP(WBMPfile.java:319) at
     WBMPcreator.WBMPfile.drawString(WBMPfile.java:340) at
     myWAPChart.doGet(myWAPChart.java:199) at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:715) at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:840) at
     com.sun.server.ServletState.callService(ServletState.java:226) at
   
com.sun.server.ServletManager.callServletService(ServletManager.java:936)
at
   
com.sun.server.http.servlet.InvokerServlet.service(InvokerServlet.java:137)
at
     javax.servlet.http.HttpServlet.service(HttpServlet.java:840) at
     com.sun.server.ServletState.callService(ServletState.java:226) at
   
com.sun.server.ServletManager.callServletService(ServletManager.java:936)
at
   
com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
at
   
com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
at
     com.sun.server.http.stages.Runner.process(Runner.java:79) at
     com.sun.server.ProcessingSupport.process(Compiled Code) at
     com.sun.server.Service.process(Service.java:204) at
   
com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java:374)
at
     com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
at
     com.sun.server.HandlerThread.run(Compiled Code)

*/
0
Comment
Question by:bimpf
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
heyhey_ earned 400 total points
ID: 2677525
    java.lang.NoClassDefFoundError: java/awt/image/BufferedImage at


java.awt.image.BufferedImage exist in Java 1.2 + but DOES NOT exist in Java 1.1

install the appropriate JDK / JRE
0
 

Author Comment

by:bimpf
ID: 2682466
..hm... I have installed jdk 1.2.1 ... and when I call "java", "javac" or any other java-program jdk 1.2.1 is used ... but obviously the java httpd server from sun doesn't use this jdk

=> do you know if I can tell the sun-javawebserver2.0 which jdk to use??? - obviously not over the classpath variable!


thanks,
klaus
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2682819
is this Java Web Server ?
better check your docs ... or call the tech support - it's possible that it does not work under 1.2 at all ... (I've never used it personally)
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:mkrainov
ID: 2682823
It's simple.  The version you use doesn't support putting the WBMPfile instance to the stream. The last version (1.11) after 03.04.2000 supports any feature you need.
0
 

Author Comment

by:bimpf
ID: 2683147
.. I've now changed my Java Web Server - settings in order to use jdk 1.2.1 ... I havn't tried version 1.11 yet  because everything works now and I'm under time-pressure

=>
if you want to get the points "heyhey" you have to place another comment so I can grade your answer ..

.... if you don't reply I'm giving the points to mkrainov because his WBMPCreator is a very useful and great utility ..

thanks to you both!
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2683225
if you want to give me the points, I suppose that you'll have to reject the current answer ... (btw. the real problem was JDK version, not the WBMPfile version)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now