regards: Johannes Koch
regards: Johannes Koch
I write java code to simulate my machine as a HTTP server,when
client
connect to my HTTP server,my HTTP server replied client a xhtml
file.
I use the HTTP headers by spec.
(1)Content-Length: (length of file which will be transmitted)
(2)Content-Type: application/vnd.wap.xhtml+xml
when I transmit a standard XHTML file,it is OK.
Nokia 6600 can identify the standard XHTML.
when I transmit a XHTML file produced by Jtidy,it is not OK.
Nokia 6600 cannot identify the XHTML file.
the following
part 1 is my java code:
part 2 is a XHTML file produced by Jtidy
--------------------------------------------
part 1:
import java.io.*;
import java.net.*;
public class HttpMirror {
public static void scopy(FileInputStream ins,OutputStream outs)
throws IOException {
synchronized (ins) {
synchronized (outs) {
System.err.println("writing nokia6600");
byte[] buf = new byte[256];
while (true) {
int br = ins.read(buf);
if (br == -1) break;
outs.write(buf,0,br);
}
}
}
}//end scopy
public static void main(String[] args) {
try {
int port = Integer.parseInt(args[0]); // The port to
listen on
ServerSocket ss = new ServerSocket(port); // Create a socket
to listen
for(;
{ // Loop forever
Socket client = ss.accept(); // Wait for a
connection
ClientThread t = new ClientThread(client); // A thread to
handle it
t.start(); // Start the thread
running
} // Loop again
}
catch (Exception e) {
System.err.println(e.getMessage());
System.err.println("Usage: java HttpMirror <port>");
}
}
static class ClientThread extends Thread {
Socket client;
ClientThread(Socket client) { this.client = client; }
public void run() {
System.err.println("server start");
try {
// Get streams to talk to the client
BufferedReader in = new BufferedReader(new
InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(new
OutputStreamWriter(client.getOutputStream()));
String line;
while((line = in.readLine()) != null) {
System.err.println(line);
if (line.length() == 0) break;
//
out.println(line);
}
out.print("HTTP/1.1 200 OK\r\n");
out.print("Date: Wed, 15 Sep 2004 13:23:51 GMT\r\n");
out.print("Server: Apache/1.3.31 (Unix) PHP/4.3.8\r\n");
out.print("Expires: Wed, 15 Sep 2004 13:33:51 GMT \r\n");
out.print("Last-Modified: Tue, 14 Sep 2004 10:00:20 GMT \r\n");
out.print("Content-Length: (length of file which will be
transmitted)\r\n");
out.print("Content-Type: application/vnd.wap.xhtml+xml \r\n\r\n");
out.flush();
FileInputStream pw = new FileInputStream("testgoogle.html");
OutputStream nokia6600 = client.getOutputStream();
//client.getOutputStream();
scopy(pw,nokia6600);
System.err.println("nokia6600 is writing out");
pw.close();
nokia6600.close();
out.close();
in.close();
client.close();
}
catch (IOException e) { /* Ignore exceptions */ }
}
}
}
--------------------------------------------
--------------------------------------------
part 2:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 1st July 2004), see
www.w3.org" />
<title>¤¸´¼¤j¾Ç -</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<meta http-equiv="Pragma" content="no-cache" />
<link href=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/nav.css"
type="text/css" rel="stylesheet" />
<script language="JavaScript1.2" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/main.js"
type="text/javascript">
</script>
<meta content="MSHTML 6.00.2800.1458" name="GENERATOR" />
</head>
<body text="#000000" bgcolor="#CDD397" leftmargin="0" topmargin=
"0">
<table height="100%" cellspacing="0" cellpadding="0" align=
"center" border="0">
<tbody>
<tr>
<td colspan="3">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="eng_line" align="right"><img height="18"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/eng-title.gif"
width="260" /></td>
</tr>
<tr>
<td class="top_img"><img height="90" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/top-main-01.jpg"
width="800" usemap="#map" border="0" /><map name=
"Map" id="Map">
<area shape="circle" alt=
"¤¸´¼¤j¾Çº¶"
coords="66,45,44" href=
"
http://www.yzu.edu.tw/" />
</map></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="left_bar" valign="top" align="middle">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="132">
<script language="JavaScript1.2" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/v-intra.js"
type="text/javascript">
</script>
</td>
</tr>
<tr>
<td align="middle"> </td>
</tr><!-- 國家品質獎 -->
<tr>
<td align="middle"><object codebase=
"
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
height="90" width="56" classid=
"clsid
27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="movie" value=
"/nqa/images/nqa.swf" />
<param name="bgcolor" value="#B6BC82" />
<embed src="/nqa/images/nqa.swf" pluginspage=
"
http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="56"
height="90" />
</object><br />
<a href=
"
http://www.yzu.edu.tw/nqa/index.htm"><img
onmouseover="JavaScript: this.style.borderColor='#CDD397';"
style=
"BORDER-RIGHT: #b6bc82 1px solid; BORDER-TOP: #b6bc82
1px solid; BORDER-LEFT: #b6bc82 1px solid; BORDER-BOTTOM: #b6bc82 1px
solid"
onmouseout=
"JavaScript: this.style.borderColor='#B6BC82';"
alt="°ß¤@ºaÀò°ê®a«~½è¼úªº¤j¾Ç¡Ð¤¸´¼¤j¾Ç"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/nqa-6.jpg"
border="0" /></a></td>
</tr><!-- 國家品質獎 -->
<tr>
<td align="middle"> </td>
</tr>
<tr>
<td style="PADDING-TOP: 3px" align="middle">
<script language="JavaScript1.2" type=
"text/javascript">
//<![CDATA[
flashon();
//]]>
</script>
</td>
</tr>
</tbody>
</table>
</td>
<td class="main" valign="top" align="middle">
<table height="100%" cellspacing="0" cellpadding="0"
width="100%" border="0">
<tbody>
<tr>
<td valign="top" height="210">
<table height="100%" cellspacing="0" cellpadding=
"0" width="100%" border="0">
<tbody>
<tr>
<!-- 即時新聞(Begin)
-->
<td class="home_hot_simg" valign="top">
<a href=
"
http://www.yzu.edu.tw/?news=040907002"><img
src="%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/040907002.jpg"
width="240" border="0" /></a></td>
<td valign="top">
<table height="100%" cellspacing="0"
cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td class="home_hot_title" height=
"25"><img height="21" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/hot-news.gif"
width="69" /></td>
</tr>
<tr>
<td class="home_hot_cont" valign=
"top">
<table class="word10" height=
"100%" cellspacing="0"
cellpadding="0" width="100%"
border="0">
<tbody>
<tr>
<td class="hot_article"
align="middle"><a href=
"
http://www.yzu.edu.tw/?news=040907002">
2004¦~¿U®Æ¹q¦À°ê»Ú¬ã°Q·|¦b¤¸´¼</a></td>
</tr>
<tr>
<td height="100%">
<p>
¿U®Æ¹q¦À¥Ñ©ó¨ä°ª®Ä²v§C¦Ã¬Vªº¯S©Ê¡A¤Îªñ¦~¨Ó§Þ³N³Ð·s¬ð¯}¡A¤w¦¨¬°¥»¥@¬ö¤½»{ªº·s¯à·½
#172;ì§Þ¡C¥xÆW¥Ø«e¬ã¨s³æ¦ì¡B¾Ç³N¬É»P²£·~¬É¥¿¿n·¥§ë¤J¬ãµo»P¥Í²£¡A³vº¥§Î¦¨¿U®Æ¹q¦À¬ãµo»E
;¨¤§Âú«¬¡C¥»®Õ§Æ±æÂǦ¹¬ã°Q·|¤§Á|¿ì¡A¶i¦æ°ê¤º¥~¬ãµo¦¨ªG¥æ¬y¡A«P¦¨¥xÆW¿U®Æ¹q¦À¬ãµo»P
8;£·~¤§¶}©ñ¥¥x(
<a href=
"
http://www.yzu.edu.tw/?news=040907002">
¸Ô²Ó</a>
)</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td><!--
即時新聞(End) -->
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table height="100%" cellspacing="0" cellpadding=
"0" width="536" border="0">
<!-- 新聞與活動 -->
<tbody>
<tr>
<td valign="top">
<table cellspacing="0" cellpadding="0"
width="536" border="0">
<!-- Title(Begin) -->
<tbody>
<tr>
<td class="home_news_title">
<table cellspacing="0"
cellpadding="0" width="536"
border="0">
<tbody>
<tr>
<td align="left">
<img height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/news-events.gif"
width="86" /></td>
</tr>
</tbody>
</table>
</td>
</tr><!-- Title(End) -->
<tr>
<td class="home_news_cont" valign=
"top">
<table cellspacing="0"
cellpadding="0" width="488"
border="0">
<tbody>
<tr>
<td valign="top" align=
"middle">
<table class="home_news"
cellspacing="0"
cellpadding="2" width=
"488" border="0">
<!-- News List (Begin)
update on 20040918 -->
<tbody>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/22/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040922005">
¤j¾Ç®Õªø¡G¬°Á׶û
·|°jÁ×</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/22/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040922004">
µûŲ
À³±Ð¾Ç¬ã¨s¨Ã«</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/22/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040922003">
¤¸´¼¤j¾Ç¬ãµo¦¨¤â¾÷¥Î¥Ò¾J¿U®Æ¹q¦À¥R¹q¾¹</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/22/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040922002">
¤¸´¼¤j¾Çp¹º¦¨¥ß±Ú¸s»P¦h¤¸¤å¤Æ¬ã¨s¤¤¤ß</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-a.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/22/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040922001">
¡y°O¾Ðªº·Å«×¢w¦Ñ·Ó¤ù®i¡z
¼x¥ó¬¡°Ê</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/17/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040917004">
¤¸´¼¤j¾Ç»P¥Ã¥¤u°ÓÄâ¤â¦X§@¾Ç¥Í¹ê²ßÀ\ÆU</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-p.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/17/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040917003">
¤½¶O¯d¾Ç³Õ¤h«á¬ã¨s¤Hû¤Î¯d¾Ç¼ú¾Çª÷</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-p.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/15/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040915001">
931¾Ç´Á¾×צW³æ¤Î¤H¤u¥[¿ï±ø¥ó¤½§i</a></td>
</tr>
<tr>
<td valign="top"
width="14">
<img height="11"
src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/r-n.gif"
width="11" align=
"absmiddle" /></td>
<td class=
"news_date" valign=
"top" width="64">
09/14/04</td>
<td width="410">
<a href=
"
http://www.yzu.edu.tw/?news=040914001">
´N¾Ç§xÃø¤§¾Ç¥Í§U¾Çª÷¥Ó½Ð</a></td>
</tr>
<!-- News List (End) -->
</tbody>
</table>
</td>
</tr>
<!-- More News (Begin) -->
<tr>
<td class="more_news"
height="18"><a href=
"
http://www.yzu.edu.tw/?news=more">
§ó¦h°T®§
...</a></td>
</tr><!-- More News (End) -->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="bottom" align="middle" height=
"100%">
<table cellspacing="0" cellpadding="0"
width="490" border="0">
<tbody>
<tr>
<td class="home_down_link" width=
"37"> </td>
<td class="home_down_link_dot"
width="16"> </td>
<td width="64"><a href=
"
http://www.yzu.edu.tw/bb/b01.htm"><img
onmouseover="this.src='/images/main/sec-item-1-h.gif';"
onmouseout=
"this.src='/images/main/sec-item-1.gif';"
height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/sec-item-1.gif"
width="64" border="0" /></a></td>
<td class="home_down_link_dot"
width="16"> </td>
<td width="64"><a href=
"
http://www.yzu.edu.tw/bb/qna.php?qna=aa">
<img onmouseover=
"this.src='/images/main/sec-item-2-h.gif';"
onmouseout=
"this.src='/images/main/sec-item-2.gif';"
height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/sec-item-2.gif"
width="64" border="0" /></a></td>
<td class="home_down_link_dot"
width="16"> </td>
<td width="64"><a href=
"
http://www.yzu.edu.tw/bb/contact.htm">
<img onmouseover=
"this.src='/images/main/sec-item-3-h.gif';"
onmouseout=
"this.src='/images/main/sec-item-3.gif';"
height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/sec-item-3.gif"
width="64" border="0" /></a></td>
<td class="home_down_link_dot"
width="16"> </td>
<td width="64"><a href=
"
http://www.yzu.edu.tw/bb/site_map.htm">
<img onmouseover=
"this.src='/images/main/sec-item-4-h.gif';"
onmouseout=
"this.src='/images/main/sec-item-4.gif';"
height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/sec-item-4.gif"
width="64" border="0" /></a></td>
<td class="home_down_link_dot"
width="16"> </td>
<td width="64"><a href=
"
http://www.yzu.edu.tw/search/index.asp">
<img onmouseover=
"this.src='/images/main/sec-item-5-h.gif';"
onmouseout=
"this.src='/images/main/sec-item-5.gif';"
height="25" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/sec-item-5.gif"
width="64" border="0" /></a></td>
<td class="home_down_link_dot"
width="16"> </td>
<td class="home_down_link" width=
"37"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="copyright_home" valign="bottom"
align="middle">Copyright @ 2004
¤¸´¼¤j¾Ç
Yuan Ze
University • ®ç¶é¿¤¤¤Ãc¥«
320
»·ªF¸ô135¸¹
- (03)4638800</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
<td class="right_bar" valign="top" align="middle">
<table cellspacing="10" cellpadding="0" width="132"
border="0">
<tbody>
<tr>
<td>
<script language="JavaScript1.2" src=
"%C2%A4%C2%B8%C2%B4%C2%BC%C2%A4j%C2%BE%C3%87%20-.files/slide_img.js"
type="text/javascript">
</script>
</td>
</tr>
<tr>
<td>
<table class="link_tb" cellspacing="0"
cellpadding="0" width="112" border="0">
<tbody>
<tr>
<td class="link_tit" align="middle">
©Û¥Í±M°Ï</td>
</tr>
<tr>
<td class="link_in" align="middle">
<p><a href=
"
http://www.yzu.edu.tw/rc/1/1.htm">¤j¾Ç³¡</a><br
/>
<a href=
"
http://www.yzu.edu.tw/rc/2/1.htm">¬ã¨s©Ò</a><br
/>
<a href=
"
http://www.yzu.edu.tw/rc/3/1.asp">±À¼s±Ð¨|</a><br
/>
<a href="
http://univ.edu.tw/univ/yzu/"
target=
"_blank">¤j¾Ç³ÕÄý·|</a></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="link_tb" cellspacing="0"
cellpadding="0" width="112" border="0">
<tbody>
<tr>
<td class="link_tit" align="middle">
®Õ¤Í¶é¦a</td>
</tr>
<tr>
<td class="link_in" align="middle">
<p><a href=
"
http://www.yzu.edu.tw/graduate/alu/free_mail.htm">
®Õ¤ÍªA°È</a><br />
<a href=
"
http://www.yzu.edu.tw/graduate/alu/alu_report_1.htm">
®Õ¤Í°ÊºA</a></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="link_tb" cellspacing="0"
cellpadding="0" width="112" border="0">
<tbody>
<tr>
<td class="link_tit" align="middle">
¥Í¬¡¼s³õ</td>
</tr>
<tr>
<td class="link_in" align="middle">
<p><a href=
"
http://www.yzu.edu.tw/arts/movie.htm">ÃÀ¤å¬¡°Ê</a><br
/>
<a href=
"
http://www.yzu.edu.tw/life.htm">¥Í¬¡¸ê°T</a></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="link_tb" cellspacing="0"
cellpadding="0" width="112" border="0">
<tbody>
<tr>
<td class="link_tit" align="middle">
§Ö³t³sµ²</td>
</tr>
<tr>
<td class="link_in" align="middle">
<p><a href=
"
http://www.yzu.edu.tw/bb/email.htm">¹q¤l¶l¥ó</a><br
/>
<a href=
"
http://isdna1.yzu.edu.tw/stdsel/default.asp"
target=
"_blank">¿ï½Ò¨t²Î</a></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="bottom_bar" colspan="3"> </td>
</tr>
</tbody>
</table>
</body>
</html>
--------------------------------------------
sorry that there are some Chinese characters.
Is there a good suggestion?
best wishes