Problem with swing-servlet communication??

Bikash Paul <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hi all friends,

I couldn't connect my servlet from my swing
interface.I want to send two parameters(userid and
password) from swing interface(it is a login dialog
box) to my servlet.Iam using Tomcat server4.0 and  I
also put entry of my servlet in web.xml file.Can any
one plz guide me how I can slove this problem.
Below r my codes:-

Swing Interface(Iam pasting only action event of my
submit button):-
================
public URL u;
public URLConnection uc;
submit.addActionListener(new ActionListener()
 {
   public void actionPerformed(ActionEvent e)
      {
        String userid1;
        String password1;
        String Content;
        String
url="http://127.0.0.1:8080/examples/servlet/loginServlet";

        userid1 = userid.getText();
        password1 = password.getText();
        System.out.println(userid1);
        System.out.println(password1);
        Content= userid1 + password1;
      try{
        u = new URL(url+"?name=" +userid1 + "&path=" +
password1);
        uc =u.openConnection();
        uc.setDoOutput(true);
        uc.setDoInput(true);
        uc.setUseCaches(false);
        printout = new
DataOutputStream(uc.getOutputStream ());
        printout.writeBytes(Content);
        printout.flush();
        printout.close();
       }catch(Exception ex){System.out.println("Error
from actionPerformed :" + ex.getMessage());}
                    }
});

Servlet file:-
=============
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class loginServlet extends HttpServlet
        {

          public void doGet(HttpServletRequest
req,HttpServletResponse res)
          throws ServletException,IOException
                {

                         res.setContentType("text/html");
                         PrintWriter out=res.getWriter();
                         String
str1=req.getParameter("name");
                         String
str2=req.getParameter("path");
                         /*DataInputStream dis;
                         dis = new
DataInputStream(req.getInputStream());

                         String str =
dis.readLine();*/
                         System.out.println(str1);
                         System.out.println(str2);
                }

        }

Regards
Bikash


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.