|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
手机用到的是用j2me所编出来的小程序。xml|天生xml|数据|数据库3.XMLTreeXSL.java
packagecom.sitechasia;
importjavax.servlet.*;
importjavax.servlet.http.*;
importjava.io.PrintWriter;
importjava.io.IOException;
publicclassXMLTreeXSLextendsHttpServlet{
PrintWriterout;
booleanflag=true;
privatestaticfinalStringCONTENT_TYPE="text/xsl";
privatestaticfinalStringCONTENT_XSL="<?xmlversion="1.0"encoding="gb2312"?><xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl">";
/**Initializeglobalvariables*/
publicvoidinit()throwsServletException{
}
/**ProcesstheHTTPGetrequest*/
publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{
try{
HttpSessionsession=request.getSession();
if(session.getAttribute("ResultEditHandle")==null){
flag=false;
}
else{
flag=true;
}
if(flag){
javax.servlet.http.Cookiecookies[]=request.getCookies();
Stringt_click_id=null;
response.setContentType(CONTENT_TYPE);
out=response.getWriter();
out.println(CONTENT_XSL);
out.println("<xsl:templatematch="/">");
out.println("<HTML>");
out.println("<HEAD><STYLE>body{FONT-SIZE:10pt;}</STYLE></HEAD>");
out.println("<BODY><xsl:apply-templatesselect="//node"/></BODY></HTML></xsl:template>");
if((cookies==null)||(cookies.length==0)){
out.println("NoClickedNode");
}
else{
for(inti=0;i<cookies.length;i++){
javax.servlet.http.Cookiec=cookies[i];
if(c.getName().equals("ClickId")){
t_click_id=c.getValue();
out.println("<xsl:templatematch="node">");
out.println("<xsl:iftest=".[number(id)$eq$"+c.getValue()+"]">");
out.println("以后点击节点的序号:<xsl:value-ofselect="id"/><br/>");
out.println("节点称号:<xsl:value-ofselect="value"/><br/>");
out.println("子节点为:<hr/>");
out.println("<xsl:for-eachselect="./node[number(father)$eq$"+t_click_id+"]">");
out.println("序号:<xsl:value-ofselect="id"/><br/>");
out.println("称号:<xsl:value-ofselect="value"/><br/>");
out.println("</xsl:for-each>");
out.println("</xsl:if>");
out.println("</xsl:template>");
out.println("</xsl:stylesheet>");
}
}
}
}
}
catch(Exceptione){
System.out.println("errror:"+e.getMessage());
e.printStackTrace();
}
}
/**Cleanupresources
*/
publicvoiddestroy(){
}
}
4.Servlet的设置,web.xml文件
<?xmlversion="1.0"?>
<!DOCTYPEweb-appPUBLIC"-//SunMicrosystems,Inc.//DTDWebApplication1.2//EN""http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>
xmlservlet
</servlet-name>
<servlet-class>
com.sitechasia.XMLServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
xmlservlet
</servlet-name>
<url-pattern>
xs
</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>
RefreshServlet
</servlet-name>
<servlet-class>
com.sitechasia.RefreshServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
RefreshServlet
</servlet-name>
<url-pattern>
rs
</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>
xmltreexsl
</servlet-name>
<servlet-class>
com.sitechasia.XMLTreeXSL
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
xmltreexsl
</servlet-name>
<url-pattern>
xmltreexsl.xsl
</url-pattern>
</servlet-mapping>
</web-app>
C#是不行的,比如说美国的航天飞船里就有java开发的程序以上是我的愚见,其实不管那种语言,你学好了,都能找到好的工作, |
|