given that I'm not really practical with Servelts, I'm trying to create a stand alone Java application based on an architecture Client-Server. Suppose I'm handling with the login of a user. The client is a simple java application (.jar) standing on the user's pc, that invoke, via an Action Listener a Servlet (standing on a server, in my case the client and server reside on the same machine), which handles the login of the user. If the user is present into the database, then the Response of the Servlet is an object User, and starts an Http Session.
Here the diagram:
Here the code of the application so far:
public class LoginForm extends JFrame {
private JTextField username;
private JTextField password;
private JButton btnOk;
private JButton btnAnnulla;
private Container c;
private JPanel loginForm;
public LoginForm() {
super();
initComponent();
}
private void initComponent() {
username = new JTextField("Username");
password = new JTextField("Password");
btnOk = new JButton("OK");
btnAnnulla = new JButton("Annulla");
//.....
btnOk.addActionListener(new btnOkListener());
}
}
Here the listener:
public class btnOkListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
//TODO: invoke LoginServlet
throw new UnsupportedOperationException("Not supported yet.");
}
}
What I have to do is to invoke the Servlet. How can I do that? May I have to create a new web application (instead a Java application) that allow me to create a Sevlet and put the jar in it or there is another way?