• 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: 9370
11
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.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!