Hi every body I am new to JSP programing.I have a java code to create an image I am unable to convert that cod ein to JSP.Can any body help me, every work can be appreciated.
Code:
Here is my JAVA code
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
 
public class ExampleCreate {
    public static void main(String[] args) throws Exception {
        final int H = 2530;
        final int W = 3630;
        int[] pixels = createPixels(W*H);
        BufferedImage image = toImage(pixels, W, H);
        display(image);
        ImageIO.write(image, "jpg", new File("static.jpg"));
    }
  
  static int[] createPixels(int size) throws Exception{
       int[] pixels = new int[size];
       int[] colors = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,102,104,106,108,110,112,114,116,118,120,122,124,126,0xff0000,0x00ff00,0x0000ff,0x00000f,0xfff000,0xff00ff,0xffffff,0xf00000};
       FileReader fr = new FileReader("SST.tmp");
       BufferedReader br = new BufferedReader(fr);
       String text = br.readLine();
       int c = 0;
       for(int i = 0; i < size; ++ i){
       		text = br.readLine();
       		c = Integer.parseInt(text);
       		if(c < 0)
       			c = 0;
       		pixels[i] = colors[c];
       }
       br.close();
   return pixels;
 }
 
    static BufferedImage toImage(int[] pixels, int w, int h) {
        DataBuffer db = new DataBufferInt(pixels, w*h);
        WritableRaster raster = Raster.createPackedRaster(db,
            w, h, w, new int[] {0xff0000, 0xff00, 0xff}, null);
        ColorModel cm = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
        return new BufferedImage(cm, raster, false, null);
    }
 
    static void display(BufferedImage image) {
        final JFrame f = new JFrame("");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new JLabel(new ImageIcon(image)));
        f.pack();
        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                f.setLocationRelativeTo(null);
                f.setVisible(true);
            }
        });
    }
}
thanks&regards
Mahender