• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

communcation between swing and servlet

 
s. anitha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to Communicate swing to servlet,by passing a string from swing to servlet.Here iam sending the sample code here.please help me.

The problem is i cant able to communicate with the servlet.

Swing part
==========


StringBuffer sb=new StringBuffer("http://localhost:8080/AppletWatch/AppServlet?colwidth=");



for(i=0, len=columnOrderPref.length; i<len; i++)
{
if(i!=0) sb.append(", ");
sb.append(columnOrderPref[i]);
}
try
{
String urlsb = sb.toString();
URL servletURL = new URL(urlsb);
URLConnection connection = servletURL.openConnection();



Servlet Part
============

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException
{

String msg = req.getParameter("colwidth");
System.out.println("MEssage"+msg);
}
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the java documentation for java.net.URLConnection. openConnection merely initiates the connection class. It does not actually send the request to the server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic