91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

JSP課程設計案例精編-源代碼做課程設計的或者畢業設計的必備品。精講。

資源截圖

代碼片段和文件信息

//WebServer.java?
import?java.net.*;
import?java.io.*;
import?java.util.*;
import?java.lang.*;
public?class?WebServer
{
???? public?static?void?main(String?args[])?{
? int?port;
ServerSocket?server_socket;
?????//讀取服務器端口號
try?{
????????????port?=?Integer.parseInt(args[0]);
? }
catch?(Exception?e)?{
?????port?=?8080;
? }
? try?{
?????//監聽服務器端口,等待連接請求
?????server_socket?=?new?ServerSocket(port);
?????System.out.println(“httpServer?running?on?port?“?+
?????????server_socket.getLocalPort());
?????//顯示啟動信息
?????while(true)?{
??Socket?socket?=?server_socket.accept();
??System.out.println(“New?connection?accepted?“?+
???????socket.getInetAddress()?+
???????“:“?+?socket.getPort());
??//創建分線程
??try?{
??????httpRequestHandler?request?=
??? new?httpRequestHandler(socket);
?????????Thread?thread?=?new?Thread(request);
??????//啟動線程
??????thread.start();
?? }
?? catch(Exception?e)?{
????? System.out.println(e);
?? }
?????}
? }
catch?(IOException?e)?{
????? System.out.println(e);
? }
????}
}
class?httpRequestHandler?implements?Runnable
{
????final?static?String?CRLF?=?“\r\n“;
????Socket?socket;
????InputStream?input;
????OutputStream?output;
????BufferedReader?br;
????//?構造方法
????public?httpRequestHandler(Socket?socket)?throws?Exception
????{
?this.socket?=?socket;
?this.input?=?socket.getInputStream();
?this.output?=?socket.getOutputStream();
?this.br?=
?????new?BufferedReader(new?InputStreamReader(socket.getInputStream()));
????}
????//?實現Runnable?接口的run()方法
????public?void?run()
????{
?try?{
????? processRequest();
?}
?catch(Exception?e)?{
????? System.out.println(e);
? }
????}
????private?void?processRequest()?throws?Exception
????{
?while(true)?{
??????//讀取并顯示Web?瀏覽器提交的請求信息
?????String?headerLine?=?br.readLine();
?????System.out.println(“The?client?request?is?“+headerLine);
?????if(headerLine.equals(CRLF)?||?headerLine.equals(““))?break;
?????StringTokenizer?s?=?new?StringTokenizer(headerLine);
?????String?temp?=?s.nextToken();
?????if(temp.equals(“GET“))?{
??String?fileName?=?s.nextToken();
??fileName?=?“.“?+?fileName?;
??//?打開所請求的文件
??FileInputStream?fis?=?null?;
??boolean?fileExists?=?true?;
??try
??????{
???fis?=?new?FileInputStream(?fileName?)?;
??????}
??catch?(?FileNotFoundException?e?)
??????{
???fileExists?=?false?;
??????}
??//?完成回應消息
??String?serverLine?=?“Server:?a?simple?java?httpServer“;
??String?statusLine?=?null;
??String?contentTypeLine?=?null;
??String?entityBody?=?null;
??String?contentLengthLine?=?“error“;
??if?(?fileExists?)
??????{
???statusLine?=?“HTTP/1.0?200?OK“?+?CRLF?;
???contentTypeLine?=?“Content-type:?“?+
???????contentType(?fileName?)?+?CRLF?;
???contentLengthLine?=?“Content-Length:?“
???????+?(new?Integer(fis.available())).toString()
???????+?CRLF;
??????}
??else
??????{
???statusLine?=?“HTTP/1.0?404?Not?Found“?+?CRLF?;
???contentTypeLine?=?“text/html“?;
???entityBody?=?“<HTML>“?+
???????“<HEAD><

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3004??2008-05-29?20:20??Softii.com\01\Readme.txt

?????文件????????288??2008-05-29?20:24??Softii.com\01\Softii.com.txt

?????文件???????4338??2005-09-04?17:52??Softii.com\01\WebServer.java

?????文件????????171??2008-05-11?13:03??Softii.com\01\人人軟件站.url

?????文件???????1067??2005-09-04?17:52??Softii.com\02\HelloWorld.jsp

?????文件???????3004??2008-05-29?20:20??Softii.com\02\Readme.txt

?????文件????????288??2008-05-29?20:24??Softii.com\02\Softii.com.txt

?????文件???????2259??2005-09-04?17:52??Softii.com\02\test_build_in_objs.jsp

?????文件????????171??2008-05-11?13:03??Softii.com\02\人人軟件站.url

?????文件???????1514??2005-09-04?17:52??Softii.com\03\addmsg.htm

?????文件???????3722??2005-09-04?17:52??Softii.com\03\addmsg.jsp

?????文件???????4269??2005-09-04?17:52??Softii.com\03\guestbook.gif

?????文件???????4464??2005-09-04?17:53??Softii.com\03\index.jsp

?????文件????????884??2005-09-04?17:53??Softii.com\03\mylinks.xml

?????文件????????519??2005-09-04?17:53??Softii.com\03\mylist.xml

?????文件???????3004??2008-05-29?20:20??Softii.com\03\Readme.txt

?????文件???????3119??2005-09-04?17:53??Softii.com\03\SAXReader.java

?????文件????????288??2008-05-29?20:24??Softii.com\03\Softii.com.txt

?????文件???????2314??2005-09-04?17:53??Softii.com\03\xmlCreator.java

?????文件???????1724??2005-09-04?17:53??Softii.com\03\xmlDisplay.java

?????文件????????171??2008-05-11?13:03??Softii.com\03\人人軟件站.url

?????文件???????3004??2008-05-29?20:20??Softii.com\04\Readme.txt

?????文件????????288??2008-05-29?20:24??Softii.com\04\Softii.com.txt

?????文件???????1673??2005-09-04?17:53??Softii.com\04\upload\error.jsp

?????文件???????3004??2008-05-29?20:20??Softii.com\04\upload\files\Readme.txt

?????文件????????288??2008-05-29?20:24??Softii.com\04\upload\files\Softii.com.txt

?????文件????????171??2008-05-11?13:03??Softii.com\04\upload\files\人人軟件站.url

?????文件????5494775??2005-09-04?17:53??Softii.com\04\upload\image\ev24492_China.jpg

?????文件???????1256??2005-09-04?17:53??Softii.com\04\upload\image\example_title.gif

?????文件?????????49??2005-09-04?17:53??Softii.com\04\upload\image\menu_bottom.gif

............此處省略464個文件信息

評論

共有 條評論