1 / 16

Web Proxy Server

Web Proxy Server. Proxy Server Introduction. Returns status and error messages. Handles http CGI requests. For more information about CGI please refer to NCSA's CGI tutorial at http://hoohoo.ncsa.uiuc.edu/cgi/ . Determines the Class to run Dynamically no code change is needed.

lajos
Télécharger la présentation

Web Proxy Server

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Proxy Server

  2. Proxy Server Introduction • Returns status and error messages. • Handles http CGI requests. • For more information about CGI please refer to NCSA's CGI tutorial at http://hoohoo.ncsa.uiuc.edu/cgi/. • Determines the Class to run Dynamically no code change is needed. • Decodes the encoded parameter list. • Is multi-threaded.

  3. The Apps Class • You can retrieve the source for the abstract Apps class on cochise at http://cochise.cs.washington.edu/~maxwell/proxy/Apps.java. • The server calls setSocket for the application passing it the socket of the connection. • This function opens a BufferedReader and a PrintWriter. • These functions are convenient for sending strings back and forth. • You can still gain access to the socket and open your own readers and writers. • The parameter list. • Inherits from Thread.

  4. Creating your own Application • Extend your class from class Apps. Implement a procedure public void run(). • This is the function, which gets called to start the thread. • Send a content type back down the output stream. • Send all your information. • Close the output stream.

  5. Wrapper Class • If you want to write your application in something other the Java you will need to create a Java wrapper class. • First create a class that extends Apps and create a function public void run(). In this function you need to do the following. String arg[] = new String[ numArgs + 1]; arg[0] = "ProgramName"; arg[1] = argument1; arg[numArgs] = null; Runtime r = Runtime.getRuntime(); Process p = r.exec(arg); Buffered Reader pIn = new BufferedReader(new InputStreamReader(p.getInputStream())); PrintWriter pOut = new PrintWriter(p.getOutputStream()); pOut.println(parm); String in; while((in = pIn.readln())) dOut = in;

  6. Schedule Client

  7. Receive Send Decode Encode We are choosing to encode requests in a URL. URL is passed. It is received and Decode sends each line of information to the Controller. Network Control Web

  8. Proxy Calendar+ JDBC mySQL Web

  9. PC GUI • The control of the GUI works as follows. • The first screen that is displayed is the login screen. • The user will login and the information is sent to the Controller to be processed. • Once the login is verified, the splash screen is displayed while information needed by the schedule GUI is received from the server. • Finally, the Main GUI is displayed. • The Main GUI enables the user to look at events from a year, month, or day perspective. • If the user wants to add an event, they will enter it in the space provided. • That information is sent to the Main GUI. • The Main GUI sends it on to the Controller. • The Controller sends it to the server.

  10. Data Processing • The Network Control is running in a separate thread than the Controller. • When processing the user login, the information is bundled up into a SendEvent and passed on to the Network Control. • The Network Control sends the event to the Encode class to be encoded into a URL string. • The the Network Control sends this string to the Send class to be sent to the server. • The Server information is stored in a class called ProxyInfo.class. If the server information changed, the class can be removed and replaced with the correct information. • When the information is sent, it opens a URL connection. • This sends back the content, which is a Buffered Input Stream. • The stream is passed by the Network Control to the Receive Class. • The Receive classes parses each line of information, sends it to the Decode class to be parsed further and sent to the Network Control. • The Network Control packages it up into a ReceiveEvent and sends it to the Controller to be processed and sent to the GUI.

  11. package schedule; import java.lang.*; import java.io.*; import java.net.*; import java.util.*; public class NetworkThread extends Thread implements SendListener { private SendEvent evt; private Vector listeners; private boolean readyToSend = false; public NetworkThread() { super(); listeners = new Vector(); } public void processSend(SendEvent evt) { // System.out.println("Getting to network send..."); if (!isAlive()) this.start(); if(!readyToSend) { this.evt = evt; readyToSend = true; } }

  12. public void addReceiveListener(ReceiveListener sl) { listeners.addElement(sl); } public void removeReceiveListener(ReceiveListener sl) { listeners.removeElement(sl); } private void notifyListeners(ReceiveEvent re) { for (int i=0; i < listeners.size(); i++) { ((ReceiveListener)listeners.elementAt(i)).processReceive(re); } } public void run() { ReceiveEvent rEvent; while (true) { if(!readyToSend) try { sleep(10); } catch (InterruptedException e) { }

  13. else { String encodedString; Encode encode = new Encode(); encodedString = encode.encodeString(evt); Send sender = new Send(); Object openStream = sender.OpenStream(encodedString); if (openStream == null ) { System.out.println("Server Down....."); readyToSend = false; notifyListeners(null); continue; } Receive receiver = new Receive(openStream); String s = null; Decode decoder = new Decode(); while ((s = receiver.readLine()) != null) { decoder.decodeNextLine(s); } rEvent = decoder.getReceiveEvent(); notifyListeners(rEvent); readyToSend = false; } } } }

  14. package schedule; import java.net.*; public class Encode { public String encodeString(SendEvent e) { String CGI; String encoded; CGI = "" + e.getApplicationName() + "?username=" + e.getUserName() + "&password=" + e.getPassWord() + "&command=" + e.getCommand() + "&" + e.getInfo(); System.out.println("Encoding string = " + CGI); encoded = URLEncoder.encode(CGI); return encoded; } }

  15. JDBC Function Calls • Loading the Driver • twz1.jdbc.mysql.jdbcMysqlDriver • Getting parameters • jdbcMysqlBase.getDefaultNames() • .jdbcMysql.properties file • Connecting • DriverManager.getConnection(url) • Connection Handle • setCatalog() • Queries • execute • Result Sets

More Related