dimanche 6 décembre 2015

Java cointainsKey() not working

I'm implementing a web project for a university class, which uses struts2, when I run the project it blocks in containsKey(). It doesn't print any of the strings.

This is some code where i'm having problems:

package fundstarter.action;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;

import java.rmi.RemoteException;
import java.util.Map;
import fundstarter.model.ConnectToRMIBean;

public class LogInAction extends ActionSupport implements SessionAware {
    private static final long serialVersionUID = 4L;
    private Map<String, Object> session;
    private String username = null;
    private String password = null;

    @Override
    public String execute() throws RemoteException {

        this.getConnectToRMIBean().setUsername(this.username);
        this.getConnectToRMIBean().setPassword(this.password);

        this.getConnectToRMIBean().logIn();


        return "done";
    }

    public void setUsername(String username) {
            this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public ConnectToRMIBean getConnectToRMIBean() {

        if(!session.containsKey("RMIBean")){
            System.out.println("hello little trouble maker");
            this.setConnectToRMIBean(new ConnectToRMIBean());
        }
        System.out.println("Hey snowball");
        return (ConnectToRMIBean) session.get("RMIBean");
    }

    public void setConnectToRMIBean(ConnectToRMIBean RMIBean) {
        System.out.println("I'm positive he's dead");
        this.session.put("RMIBean", RMIBean);
    }

    @Override
    public void setSession(Map<String, Object> arg0) {
        // TODO Auto-generated method stub

    }
}

My code is exactly like one that my professor wrote, and i can't figure out what is wrong with my code?




Aucun commentaire:

Enregistrer un commentaire