aspose file tools*
The moose likes I/O and Streams and the fly likes String sending in an applet to servlet servlet to applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "String sending in an applet to servlet servlet to applet" Watch "String sending in an applet to servlet servlet to applet" New topic
Author

String sending in an applet to servlet servlet to applet

The_Hobo_Phoenix
Greenhorn

Joined: Jan 22, 2003
Posts: 3
I have a problem in sending strings and i dont know where to put the code to transfer the string can anyone help please
Where do i put this code to send a string from the applet to the servlet and from the servlet to the applet.
// this is my applet
import java.applet.Applet;
import java.awt.*; // import the java.awt package
import java.awt.event.*; // import the java.awt.event package
import java.lang.*;
import java.lang.String;
import java.sql.*;//?
import java.io.*;
import java.util.*;//?
import java.net.*;
import javax.swing.*;//?

public class tta1 extends Applet implements ActionListener {
public void init()
{
}//init

public void paint(Graphics g)
{
//outputting strings too screen here, into cells in a timetable.
}//paint()

// process user's action in TextField input
public void actionPerformed( ActionEvent e )
{

repaint();//Force paint to be invoked
}
}//tta1
//this is the servlet-------------------------------------------------

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.net.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class SerChk extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
//Initialize global variables

public void init() throws ServletException {
}

//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<font color=\"green\">");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</font>");
String outputline;
while((outputLine = out.writeline()) != null)
system.out,println(inputLine);
in.close();
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>SerChk</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a POST. This is the reply.</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}

//buffer code----------------------------------------

import java.net.*;
import java.io.*;
public class URLConnectionReader{
public static void main(string[] args) throws Exception {
URL myUrl = new URL("http://");
URLConnection uc = myURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream())));
String inputline;
while((inputLine = in.readline()) != null)
system.out,println(inputLine);
in.close();
}}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String sending in an applet to servlet servlet to applet
 
Similar Threads
problem with response commitment
a simple filter with a simple question.
String sending in an applet to servlet servlet to applet
problem with urldecoder in doGet mehtod
sending image from servelt to SVG file