⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleservlet.java

📁 大量j2me源代码
💻 JAVA
字号:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SimpleServlet extends HttpServlet
{
   public void doPost(HttpServletRequest req, HttpServletResponse res)
           throws ServletException, IOException
   {
      // open up the input stream and convert it into a string
      InputStream in = req.getInputStream();
      int requestLength = req.getContentLength();
      if (requestLength > 0)
      {
         StringBuffer sb = new StringBuffer(requestLength);
         for (int i=0; i < requestLength; i++)
         {
            int c = in.read();
            if (c == -1)
               break;
            else
               sb.append((char)c);
         }
         in.close();
         String rs = sb.toString();
         System.out.println("Got request: " + rs);
      }

      // process things
      // do something with the request

      // send back a response
      res.setContentType("text/plain");
      PrintWriter out = res.getWriter();
      out.write( " HELLO ");
      out.close();
   }

   public void doGet(HttpServletRequest req, HttpServletResponse res)
           throws ServletException, IOException
   {
      doPost(req, res);
   }

}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -