色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

J2ME/J2EE實(shí)現(xiàn)用戶(hù)登錄交互 實(shí)現(xiàn)代碼

服務(wù)器代碼:
LoginServlet:
package com;
復(fù)制代碼 代碼如下:
import Java.io.ByteArrayOutputStream;
import Java.io.DataOutputStream;
import Java.io.IOException;
import Java.io.OutputStream;
import Javax.servlet.ServletException;
import Javax.servlet.http.HttpServlet;
import Javax.servlet.http.HttpServletRequest;
import Javax.servlet.http.HttpServletResponse;
/** *//*******************************************************************************
*
* @author zdw
*
*/
@SuppressWarnings("serial")
public class LoginServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// 得到客戶(hù)端傳入的數(shù)據(jù)(用戶(hù)名和密碼)
String username = request.getParameter("username");
String password = request.getParameter("password");
// 構(gòu)建輸出流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
// 邏輯操作(這里寫(xiě)你的邏輯判斷)
if ("zdw".equals(username) && "admin".equals(password))
{
// 響應(yīng)數(shù)據(jù)
dos.writeUTF("true");
} else
{
// 響應(yīng)數(shù)據(jù)
dos.writeUTF("false");
}
//
byte[] data = baos.toByteArray();
// 設(shè)置服務(wù)器響應(yīng)參數(shù)
response.setStatus(HttpServletResponse.SC_OK);
response.setContentLength(data.length);
response.setContentType("application/octet-stream");
OutputStream os = response.getOutputStream();
os.write(data);
os.close();
}
}

源碼下載:點(diǎn)此下載
注意此工程為MyEclipse工程,您需要安裝wtk和tomcat才能正常運(yùn)行此程序.
登錄圖:

jsp技術(shù)J2ME/J2EE實(shí)現(xiàn)用戶(hù)登錄交互 實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 达拉特旗| 札达县| 绥芬河市| 玉田县| 福州市| 霍城县| 喜德县| 高平市| 康平县| 页游| 黔南| 泰和县| 西乌| 镶黄旗| 咸宁市| 宿迁市| 福州市| 会泽县| 隆德县| 临漳县| 蓬莱市| 北宁市| 嘉禾县| 普格县| 梧州市| 将乐县| 龙泉市| 浙江省| 彭水| 内乡县| 金山区| 平昌县| 韩城市| 双城市| 墨竹工卡县| 都匀市| 惠安县| 梅河口市| 山阳县| 甘泉县| 阳春市|