{"id":10198,"date":"2015-08-25T00:00:32","date_gmt":"2015-08-25T04:00:32","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10198"},"modified":"2015-08-24T08:40:26","modified_gmt":"2015-08-24T12:40:26","slug":"webclient-client-application-that-can-talk-interactively-to-web-servers-requires-the-components-listed-below","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10198","title":{"rendered":"WebClient &#8211; Client application that can talk interactively to Web servers. Requires the components listed below"},"content":{"rendered":"<pre>import java.awt.*; \/\/ For BorderLayout, GridLayout, Font, Color.\r\nimport java.awt.event.*;\r\nimport java.util.*;\r\nimport javax.swing.*;\r\n\r\n\/** A graphical client that lets you interactively connect to\r\n\u00a0*\u00a0 Web servers and send custom request lines and\r\n\u00a0*\u00a0 request headers.\r\n\u00a0*\r\n\u00a0*\u00a0 Taken from Core Web Programming from\r\n\u00a0*\u00a0 Prentice Hall and Sun Microsystems Press,\r\n\u00a0*\u00a0 .\r\n\u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown;\r\n\u00a0*\u00a0 may be freely used or adapted.\r\n\u00a0*\/\r\n\r\npublic class WebClient extends JPanel\r\n\u00a0\u00a0\u00a0 implements Runnable, Interruptible, ActionListener {\r\n\u00a0 public static void main(String[] args) {\r\n\u00a0\u00a0\u00a0 WindowUtilities.setNativeLookAndFeel();\r\n\u00a0\u00a0\u00a0 WindowUtilities.openInJFrame(new WebClient(), 600, 700,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"Web Client\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SystemColor.control);\r\n\u00a0 }\r\n\r\n\u00a0 private LabeledTextField hostField, portField,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 requestLineField;\r\n\u00a0 private JTextArea requestHeadersArea, resultArea;\r\n\u00a0 private String host, requestLine;\r\n\u00a0 private int port;\r\n\u00a0 private String[] requestHeaders = new String[30];\r\n\u00a0 private JButton submitButton, interruptButton;\r\n\u00a0 private boolean isInterrupted = false;\r\n\r\n\u00a0 public WebClient() {\r\n\u00a0\u00a0\u00a0 setLayout(new BorderLayout(5, 30));\r\n\u00a0\u00a0\u00a0 int fontSize = 14;\r\n\u00a0\u00a0\u00a0 Font labelFont =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(\"Serif\", Font.BOLD, fontSize);\r\n\u00a0\u00a0\u00a0 Font headingFont =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(\"SansSerif\", Font.BOLD, fontSize+4);\r\n\u00a0\u00a0\u00a0 Font textFont =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(\"Monospaced\", Font.BOLD, fontSize-2);\r\n\u00a0\u00a0\u00a0 JPanel inputPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 inputPanel.setLayout(new BorderLayout());\r\n\u00a0\u00a0\u00a0 JPanel labelPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 labelPanel.setLayout(new GridLayout(4,1));\r\n\u00a0\u00a0\u00a0 hostField = new LabeledTextField(\"Host:\", labelFont,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 30, textFont);\r\n\u00a0\u00a0\u00a0 portField = new LabeledTextField(\"Port:\", labelFont,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"80\", 5, textFont);\r\n\u00a0\u00a0\u00a0 \/\/ Use HTTP 1.0 for compatibility with the most servers.\r\n\u00a0\u00a0\u00a0 \/\/ If you switch this to 1.1, you *must* supply a\r\n\u00a0\u00a0\u00a0 \/\/ Host: request header.\r\n\u00a0\u00a0\u00a0 requestLineField =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new LabeledTextField(\"Request Line:\", labelFont,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"GET \/ HTTP\/1.0\", 50, textFont);\r\n\u00a0\u00a0\u00a0 labelPanel.add(hostField);\r\n\u00a0\u00a0\u00a0 labelPanel.add(portField);\r\n\u00a0\u00a0\u00a0 labelPanel.add(requestLineField);\r\n\u00a0\u00a0\u00a0 JLabel requestHeadersLabel =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JLabel(\"Request Headers:\");\r\n\u00a0\u00a0\u00a0 requestHeadersLabel.setFont(labelFont);\r\n\u00a0\u00a0\u00a0 labelPanel.add(requestHeadersLabel);\r\n\u00a0\u00a0\u00a0 inputPanel.add(labelPanel, BorderLayout.NORTH);\r\n\u00a0\u00a0\u00a0 requestHeadersArea = new JTextArea(5, 80);\r\n\u00a0\u00a0\u00a0 requestHeadersArea.setFont(textFont);\r\n\u00a0\u00a0\u00a0 JScrollPane headerScrollArea =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JScrollPane(requestHeadersArea);\r\n\u00a0\u00a0\u00a0 inputPanel.add(headerScrollArea, BorderLayout.CENTER);\r\n\u00a0\u00a0\u00a0 JPanel buttonPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 submitButton = new JButton(\"Submit Request\");\r\n\u00a0\u00a0\u00a0 submitButton.addActionListener(this);\r\n\u00a0\u00a0\u00a0 submitButton.setFont(labelFont);\r\n\u00a0\u00a0\u00a0 buttonPanel.add(submitButton);\r\n\u00a0\u00a0\u00a0 inputPanel.add(buttonPanel, BorderLayout.SOUTH);\r\n\u00a0\u00a0\u00a0 add(inputPanel, BorderLayout.NORTH);\r\n\u00a0\u00a0\u00a0 JPanel resultPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 resultPanel.setLayout(new BorderLayout());\r\n\u00a0\u00a0\u00a0 JLabel resultLabel =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JLabel(\"Results\", JLabel.CENTER);\r\n\u00a0\u00a0\u00a0 resultLabel.setFont(headingFont);\r\n\u00a0\u00a0\u00a0 resultPanel.add(resultLabel, BorderLayout.NORTH);\r\n\u00a0\u00a0\u00a0 resultArea = new JTextArea();\r\n\u00a0\u00a0\u00a0 resultArea.setFont(textFont);\r\n\u00a0\u00a0\u00a0 JScrollPane resultScrollArea =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JScrollPane(resultArea);\r\n\u00a0\u00a0\u00a0 resultPanel.add(resultScrollArea, BorderLayout.CENTER);\r\n\u00a0\u00a0\u00a0 JPanel interruptPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 interruptButton = new JButton(\"Interrupt Download\");\r\n\u00a0\u00a0\u00a0 interruptButton.addActionListener(this);\r\n\u00a0\u00a0\u00a0 interruptButton.setFont(labelFont);\r\n\u00a0\u00a0\u00a0 interruptPanel.add(interruptButton);\r\n\u00a0\u00a0\u00a0 resultPanel.add(interruptPanel, BorderLayout.SOUTH);\r\n\u00a0\u00a0\u00a0 add(resultPanel, BorderLayout.CENTER);\r\n\u00a0 }\r\n\r\n\u00a0 public void actionPerformed(ActionEvent event) {\r\n\u00a0\u00a0\u00a0 if (event.getSource() == submitButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 Thread downloader = new Thread(this);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 downloader.start();\r\n\u00a0\u00a0\u00a0 } else if (event.getSource() == interruptButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 isInterrupted = true;\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 public void run() {\r\n\u00a0\u00a0\u00a0 isInterrupted = false;\r\n\u00a0\u00a0\u00a0 if (hasLegalArgs())\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new HttpClient(host, port, requestLine,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 requestHeaders, resultArea, this);\r\n\u00a0 }\r\n\r\n\u00a0 public boolean isInterrupted() {\r\n\u00a0\u00a0\u00a0 return(isInterrupted);\r\n\u00a0 }\r\n\r\n\u00a0 private boolean hasLegalArgs() {\r\n\u00a0\u00a0\u00a0 host = hostField.getTextField().getText();\r\n\u00a0\u00a0\u00a0 if (host.length() == 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 report(\"Missing hostname\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 return(false);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 String portString =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 portField.getTextField().getText();\r\n\u00a0\u00a0\u00a0 if (portString.length() == 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 report(\"Missing port number\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 return(false);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 port = Integer.parseInt(portString);\r\n\u00a0\u00a0\u00a0 } catch(NumberFormatException nfe) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 report(\"Illegal port number: \" + portString);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 return(false);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 requestLine =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 requestLineField.getTextField().getText();\r\n\u00a0\u00a0\u00a0 if (requestLine.length() == 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 report(\"Missing request line\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 return(false);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 getRequestHeaders();\r\n\u00a0\u00a0\u00a0 return(true);\r\n\u00a0 }\r\n\r\n\u00a0 private void report(String s) {\r\n\u00a0\u00a0\u00a0 resultArea.setText(s);\r\n\u00a0 }\r\n\r\n\u00a0 private void getRequestHeaders() {\r\n\u00a0\u00a0\u00a0 for(int i=0; i\r\n\u00a0\u00a0 *\u00a0\u00a0\u00a0 LabeledTextField ltf = new LabeledTextField(...);\r\n\u00a0\u00a0 *\u00a0\u00a0\u00a0 ltf.getLabel().someLabelMethod(...);\r\n\u00a0\u00a0 *<\/pre>\n<p style=\"text-align: justify;\">*\/ public JLabel getLabel() { return(label); } \/** The TextField at the right side of the * LabeledTextField. *\/ public JTextField getTextField() { return(textField); } } Interruptible.java Polls to see if the user choose to interrupt the current network download. \/** An interface for classes that can be polled to see * if they&#8217;ve been interrupted. Used by HttpClient * and WebClient to allow the user to interrupt a network * download. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public interface Interruptible { public boolean isInterrupted(); } NetworkClient.java Starting point for a network client to communicate with a remote computer. import java.net.*; import java.io.*; \/** A starting point for network clients. You&#8217;ll need to * override handleConnection, but in many cases connect can * remain unchanged. It uses SocketUtil to simplify the * creation of the PrintWriter and BufferedReader. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class NetworkClient { protected String host; protected int port; \/** Register host and port. The connection won&#8217;t * actually be established until you call * connect. *\/ public NetworkClient(String host, int port) { this.host = host; this.port = port; } \/** Establishes the connection, then passes the socket * to handleConnection. *\/ public void connect() { try { Socket client = new Socket(host, port); handleConnection(client); } catch(UnknownHostException uhe) { System.out.println(&#8220;Unknown host: &#8221; + host); uhe.printStackTrace(); } catch(IOException ioe) { System.out.println(&#8220;IOException: &#8221; + ioe); ioe.printStackTrace(); } } \/** This is the method you will override when * making a network client for your task. * The default version sends a single line * (&#8220;Generic Network Client&#8221;) to the server, * reads one line of response, prints it, then exits. *\/ protected void handleConnection(Socket client) throws IOException { PrintWriter out = SocketUtil.getWriter(client); BufferedReader in = SocketUtil.getReader(client); out.println(&#8220;Generic Network Client&#8221;); System.out.println (&#8220;Generic Network Client:\\n&#8221; + &#8220;Made connection to &#8221; + host + &#8221; and got &#8216;&#8221; + in.readLine() + &#8220;&#8216; in response&#8221;); client.close(); } \/** The hostname of the server we&#8217;re contacting. *\/ public String getHost() { return(host); } \/** The port connection will be made on. *\/ public int getPort() { return(port); } } SocketUtil.java: Provides utilities for wrapping a BufferedReader and PrintWriter around the Socket&#8217;s input and output streams, respectively. import java.net.*; import java.io.*; \/** A shorthand way to create BufferedReaders and * PrintWriters associated with a Socket. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class SocketUtil { \/** Make a BufferedReader to get incoming data. *\/ public static BufferedReader getReader(Socket s) throws IOException { return(new BufferedReader( new InputStreamReader(s.getInputStream()))); } \/** Make a PrintWriter to send outgoing data. * This PrintWriter will automatically flush stream * when println is called. *\/ public static PrintWriter getWriter(Socket s) throws IOException { \/\/ Second argument of true means autoflush. return(new PrintWriter(s.getOutputStream(), true)); } } WindowUtilities.java Simplifies the setting of native look and feel. import javax.swing.*; import java.awt.*; \/\/ For Color and Container classes. \/** A few utilities that simplify using windows in Swing. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class WindowUtilities { \/** Tell system to use native look and feel, as in previous * releases. Metal (Java) LAF is the default otherwise. *\/ public static void setNativeLookAndFeel() { try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { System.out.println(&#8220;Error setting native LAF: &#8221; + e); } } public static void setJavaLookAndFeel() { try { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); } catch(Exception e) { System.out.println(&#8220;Error setting Java LAF: &#8221; + e); } } public static void setMotifLookAndFeel() { try { UIManager.setLookAndFeel( &#8220;com.sun.java.swing.plaf.motif.MotifLookAndFeel&#8221;); } catch(Exception e) { System.out.println(&#8220;Error setting Motif LAF: &#8221; + e); } } \/** A simplified way to see a JPanel or other Container. Pops * up a JFrame with specified Container as the content pane. *\/ public static JFrame openInJFrame(Container content, int width, int height, String title, Color bgColor) { JFrame frame = new JFrame(title); frame.setBackground(bgColor); content.setBackground(bgColor); frame.setSize(width, height); frame.setContentPane(content); frame.addWindowListener(new ExitListener()); frame.setVisible(true); return(frame); } \/** Uses Color.white as the background color. *\/ public static JFrame openInJFrame(Container content, int width, int height, String title) { return(openInJFrame(content, width, height, title, Color.white)); } \/** Uses Color.white as the background color, and the * name of the Container&#8217;s class as the JFrame title. *\/ public static JFrame openInJFrame(Container content, int width, int height) { return(openInJFrame(content, width, height, content.getClass().getName(), Color.white)); } } ExitListener.java WindowListener for applications in this chapter. import java.awt.*; import java.awt.event.*; \/** A listener that you attach to the top-level JFrame of * your application, so that quitting the frame exits the * application. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class ExitListener extends WindowAdapter { public void windowClosing(WindowEvent event) { System.exit(0); } }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>import java.awt.*; \/\/ For BorderLayout, GridLayout, Font, Color. import java.awt.event.*; import java.util.*; import javax.swing.*; \/** A graphical client that lets you interactively connect to \u00a0*\u00a0 Web servers and send custom request lines and \u00a0*\u00a0 request headers. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10198\">Continue reading<\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1417,1424],"tags":[840,706,308,285],"class_list":["post-10198","post","type-post","status-publish","format-standard","hentry","category-code-programming-samples--","category-javaj2eej2me","tag-client","tag-code","tag-java","tag-285","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26597,"url":"http:\/\/bangla.sitestree.com\/?p=26597","url_meta":{"origin":10198,"position":0},"title":"WebClient &#8211; Client application that can talk interactively to Web servers. Requires the components listed below #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 29, 2021","format":false,"excerpt":"WebClient - Client application that can talk interactively to Web servers. Requires the components listed below import java.awt.*; \/\/ For BorderLayout, GridLayout, Font, Color. import java.awt.event.*; import java.util.*; import javax.swing.*; \/** A graphical client that lets you interactively connect to * Web servers and send custom request lines and *\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26589,"url":"http:\/\/bangla.sitestree.com\/?p=26589","url_meta":{"origin":10198,"position":1},"title":"AddressVerifier.java  Connects to an SMTP server and issues a expn request to display details about a mailbox on the server. Uses the following classes: #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 29, 2021","format":false,"excerpt":"AddressVerifier.java Connects to an SMTP server and issues a expn request to display details about a mailbox on the server. Uses the following classes: import java.net.*; import java.io.*; \/** Given an e-mail address of the form user@host, * connect to port 25 of the host and issue an * 'expn'\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10189,"url":"http:\/\/bangla.sitestree.com\/?p=10189","url_meta":{"origin":10198,"position":2},"title":"AddressVerifier.java Connects to an SMTP server and issues a expn request to display details about a mailbox on the server. Uses the following classes","author":"","date":"August 24, 2015","format":false,"excerpt":"import java.net.*; import java.io.*; \/** Given an e-mail address of the form user@host, \u00a0*\u00a0 connect to port 25 of the host and issue an \u00a0*\u00a0 'expn' request for the user. Print the results. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 .\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26489,"url":"http:\/\/bangla.sitestree.com\/?p=26489","url_meta":{"origin":10198,"position":3},"title":"UriRetriever.java  Accepts a host, port, and file from the command line and retrieves the implied URL from the HTTP server by issuing a GET request. Uses the following classes: #Programming Code Examples #NULL #Network Programming","author":"Author-Check- Article-or-Video","date":"April 26, 2021","format":false,"excerpt":"UriRetriever.java Accepts a host, port, and file from the command line and retrieves the implied URL from the HTTP server by issuing a GET request. Uses the following classes: import java.net.*; import java.io.*; \/** Retrieve a URL given the host, port, and file as three * separate command-line arguments. A\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26743,"url":"http:\/\/bangla.sitestree.com\/?p=26743","url_meta":{"origin":10198,"position":4},"title":"ThreadedEchoServer.java  A multithreaded version of EchoServer, where each client request is serviced on a separate thread. Requires the following classes: #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 30, 2021","format":false,"excerpt":"ThreadedEchoServer.java A multithreaded version of EchoServer, where each client request is serviced on a separate thread. Requires the following classes: import java.net.*; import java.io.*; \/** A multithreaded variation of EchoServer. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10181,"url":"http:\/\/bangla.sitestree.com\/?p=10181","url_meta":{"origin":10198,"position":5},"title":"ShowSession.java Servlet that uses session tracking to determine if the client is a repeat visitor. Uses the ServletUtilities class to simplify the DOCTYPE and HEAD output.","author":"","date":"August 21, 2015","format":false,"excerpt":"ShowSession.java Servlet that uses session tracking to determine if the client is a repeat visitor. Uses the ServletUtilities class to simplify the DOCTYPE and HEAD output. package cwp; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.net.*; import java.util.*; \/** Simple example of session tracking. * * Taken from Core Web\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10198"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10198\/revisions"}],"predecessor-version":[{"id":10199,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10198\/revisions\/10199"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10198"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}