Solved

java servlet & creating wbmp images

Posted on 2000-04-02
6
268 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

803 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