#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    14
    Rep Power
    0

    accessing applets from servlets


    hi

    I am trying to access an applet from a servlet .Everytime i run the servlet , it just shows a blank image .The applet contains a pie chart and is compiling well.Can someone tell where i am going wrong .....???

    Applet CODE :
    -------------------------------------------
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;

    public class PieChart extends Applet implements ActionListener
    {

    int red, blue, green, yellow;

    Label instrutions= new Label("Enter 4 dollar amounts for your
    investment portfolio and press ENTER in box 4. ");
    Label highRisk = new Label("High Risk");
    Label mediumRisk = new Label("Medium Risk");
    Label lowRisk = new Label("Low Risk");
    Label noRisk = new Label("No Risk");

    TextField txtHighRisk = new TextField(" ", 10);
    TextField txtMediumRisk = new TextField(" ", 10);
    TextField txtLowRisk = new TextField(" ", 10);
    TextField txtNoRisk = new TextField(" ", 10);

    static private int CIRCLE= 360;

    public void init()
    {
    add(instrutions);
    add(highRisk);
    add(txtHighRisk);
    add(mediumRisk);
    add(txtMediumRisk);
    add(lowRisk);
    add(txtLowRisk);
    add(noRisk);
    add(txtNoRisk);
    txtNoRisk.addActionListener(this);
    }

    public void actionPerformed(ActionEvent thisEvent)
    {


    int intHighRisk = Integer.parseInt(txtHighRisk.getText ());
    int intMediumRisk = Integer.parseInt
    (txtMediumRisk.getText());
    int intLowRisk = Integer.parseInt(txtLowRisk.getText());
    int intNoRisk = Integer.parseInt(txtNoRisk.getText());

    red = intHighRisk * CIRCLE;
    blue = intMediumRisk * CIRCLE;
    green = intLowRisk * CIRCLE;
    yellow = intNoRisk * CIRCLE;

    repaint();
    }


    public void paint(Graphics gr)
    {
    gr.setColor(Color.red);
    gr.fillArc(200, 200, 100, 100, 360, red);
    gr.setColor(Color.blue);
    gr.fillArc(200, 200, 100, 100, red, blue);
    gr.setColor(Color.yellow);
    gr.fillArc(200, 200, 100, 100, blue, yellow);
    gr.setColor(Color.green);
    gr.fillArc(200, 200, 100, 100, yellow, green);
    }
    }

    ---------------------------------------------------
    servlet CODE
    ---------------------------------------------------
    import java.sql.*;
    import java.lang.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class PieChartS extends HttpServlet
    {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    {
    res.setContentType("text/html");
    ServletOutputStream out = res.getOutputStream();
    out.println("<html><head><title>pie</title></head><body>");
    out.println("<APPLET CODE=\"/home/lnayar/baais/xmlServlet/PieChart.class\" HEIGHT=280 WIDTH=460>");
    out.println("</APPLET>");
    out.println("</body></html>");
    }
    }

    ---------------------------------------------------------

    am trying to create a piechart in servlets . can someone give sggestions as to how to do it ..
    PLS help me ....
    Thx
    prabhu
  2. #2
  3. Senior Polecat
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Jersey (the original version)
    Posts
    210
    Rep Power
    11
    hate to break it to you but you're in the wrong forum this is graphic design ... try the JAVA forum...

IMN logo majestic logo threadwatch logo seochat tools logo