Link to home
Start Free TrialLog in
Avatar of tropocolo
tropocolo

asked on

Applet don't work

I can's get the parameters from html page. I include the code of html and how I get the parameters.
The applet is in a jar file, do I Have to do something more????
For server I use GlassfishV2
Thanks
html Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
   <head>
   </head>
   <body>
       <meta http-equiv="Content-Language" content="es-ES" />
      <applet code="com.ipsca.applet.ApplicationManager" archive="MyApplet.jar" 
        codebase="http://localhost:8150/cargaApplet/" width=300 height=150 alt="esto no rula">
            <PARAM NAME="commonName" VALUE="Applet"/>
            <param name="email" value="applet@applet.com"/>
            <param name="idUser" value="16"/>
            <param name="activationCode" value="7"/>
            <param name="revocationCode" value="9"/>
            <param name="organization" value="applet"/>
      </applet>
   </body>
</html>
This is how I get the parameters in my class
 
 private void ObtenerValoresParametros() {
        System.out.println("before getParameter()");
        user.setName(getParameter("commonName"));
        user.setIdUser(getParameter("idUser"));
        user.setEmail(getParameter("email"));
        user.setActivationCode(getParameter("activationCode"));
        user.setRevocationCode(getParameter("revocationCode"));
        user.setOrganizacion(getParameter("organization"));
    }

Open in new window

Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

That 'class' will have to be the applet. is it?
do you see any exception?
Avatar of tropocolo
tropocolo

ASKER

Yes,
java.lang.NullPointerException
        at java.applet.Applet.getParameter(Applet.java:174)
        at com.ipsca.applet.ApplicationManager.ObtenerValoresParametros(ApplicationManager.java:82)
        at com.ipsca.applet.ApplicationManager.init(ApplicationManager.java:60)
        at sun.applet.AppletPanel.run(AppletPanel.java:425)
        at java.lang.Thread.run(Thread.java:619)
I think that my Applet don't receive the parameters.. Or it can access them
>>I think that my Applet don't receive the parameters.. Or it can access them

not actually, in this case, it should return null!

looks like it is not properly initialized as applet!
how do you invoke the applet?
or DocumentListener

<applet code="com.ipsca.applet.ApplicationManager" archive="MyApplet.jar"

If it isn't, I don't understand the question
sorry ignore the alst comment!
Well, maybe can be this

I invoque the metod in init()
>>I don't understand the question

do you access throw browser?
ah, ok
I compile the jar, then I use an html to invoke it using a browser. The url is
http://localhost:8150/cargaApplet/cargaApplet.html
The jar is in the same directory as cargaApplet.html


are you callling the init in constructor?
can you post the code of constructor and init method?
This is the applet code
public class ApplicationManager extends JApplet {

    private static final long serialVersionUID = 1L;
    // Variables declaration
    private javax.swing.JProgressBar barraProgreso;
    private javax.swing.JButton btnSiguiente;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JTextArea txtArea;    //Datos del usuario y para la generacion del CSR
    private User user = new User();
 public ApplicationManager() {
    }

    @Override
    public void init() {
        initComponents();
        ObtenerValoresParametros();
      }
   
    @Override
   public void start(){
     try {
            obtenerPassword();
        } catch (Exception ex) {
            Logger.getLogger(ApplicationManager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
private void ObtenerValoresParametros() {
        System.out.println("before getParameter()");
        user.setName(getParameter("commonName"));
        user.setIdUser(getParameter("idUser"));
        user.setEmail(getParameter("email"));
        user.setActivationCode(getParameter("activationCode"));
        user.setRevocationCode(getParameter("revocationCode"));
        user.setOrganizacion(getParameter("organization"));
    }
 initComponents()
{....code....}
}
private void ObtenerValoresParametros() {
        System.out.println( "isActive(): " + isActive );

can yu print this and post the result?
This is the result
isActive:false

It's bad, isn't it?
>>It's bad, isn't it?

yes, very much!

do you see any other exception stack along with the NullPointer...?
No, it's the only exception, I'm going to try surround it with try
No way, There is no other exception there
whats there is initComponents()?
I initialize the applet components

jPanel1 = new javax.swing.JPanel();
        lblTitulo = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtArea = new javax.swing.JTextArea();
        barraProgreso = new javax.swing.JProgressBar();
        btnSiguiente = new javax.swing.JButton();

        setStub(null);

        lblTitulo.setFont(new java.awt.Font("Courier New", 0, 14)); // NOI18N
        lblTitulo.setText("    ");
        lblTitulo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        lblTitulo.setFocusable(false);

        txtArea.setColumns(20);
        txtArea.setEditable(false);
        txtArea.setRows(2);
        txtArea.setAutoscrolls(false);
        jScrollPane1.setViewportView(txtArea);

        btnSiguiente.setText("Next");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addComponent(btnSiguiente).addGap(18, 18, 18).addComponent(barraProgreso, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)).addComponent(jScrollPane1).addComponent(lblTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(lblTitulo).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(btnSiguiente).addComponent(barraProgreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        lblTitulo.getAccessibleContext().setAccessibleName("lblCertificate");
        btnSiguiente.getAccessibleContext().setAccessibleName("btnSiguiente");
        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
ASKER CERTIFIED SOLUTION
Avatar of ksivananth
ksivananth
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
btw, why did you do that?
I DID IT!!!!!!!!

thanks you

by the way, I didn't do that, NetBeans did it.....
I only have seen it when I've sent to you....

But Very thanks, I resolve the question!!!!