• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

String sending in an applet to servlet servlet to applet

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}}
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic