?? testchineseservlet.java
字號:
package dli2fe.test;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;/** * Title: Digial Library Interoperable Interface Fudan Edition * Description: This project contains all the classes required for DLI2FE interface. Developers use these classes to implement the wrapper and client side codes. The basic functions of DLI2FE is as follows: * Search: Search a digital library source site. * Metadata: Fetch metadata for a site. * ResultAccess: Get results for a given query. * DLI2FE uses Dublin Core as the basic attribute model, DAV/DASL as the general XML-based query language and CORBA as distributed object transportation mechanism. * Copyright: Copyright (c) 2001 * Company: Fudan University * @author Carl Tao * @version 1.0 */public class TestChineseServlet extends HttpServlet { private static final String CONTENT_TYPE = "text/html; charset=GBK"; /**Initialize global variables*/ public void init() throws ServletException { } /**Process the HTTP Get request*/ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String yourName = ""; response.setLocale(Locale.PRC); // to show Chinese character correctly response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<head>"); out.println("<title>Chinese Test for Servlet</title>"); out.println("</head>"); out.println("<body bgcolor=\"white\">"); out.println("<h3>Chinese Test for Servlet</h3>"); try { yourName = request.getParameter("yourname"); yourName = new String(notNull(yourName).getBytes("ISO-8859-1")); // convert to platform's default encodings } catch(Exception e) { e.printStackTrace(); } out.println("本次輸入的參數(shù):<br>"); if (yourName != null) { out.println("你的名字="); out.println(yourName + "<br>"); } else { out.println("無參數(shù)輸入。"); } out.println("<P>"); out.print("<form action=\""); out.print("/TestChinese/testchineseservlet\" "); out.println("method=POST>"); out.println("你的名字:"); out.println("<input type=text size=20 name=yourname>"); out.println("<br>"); out.println("<input type=submit>"); out.println("</form>"); out.println("</body>"); out.println("</html>"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } String notNull(String s) { return s == null ? "" : s; } /**Clean up resources*/ public void destroy() { }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -