jsp服務端客戶端源碼,jsp源碼之家

本文目錄一覽:

運行JSP頁面顯示源碼

localhost:8080 tomcat的主頁打得開嗎?

打不開的話就是項目沒有配置到Tomcat,打得開的話新建一個運行再試試。

網上下的jsp源碼要怎麼用

需要部署到服務器中

找到菜單 window → Show View → Servers,打開Servers視圖標籤,部署的Tomcat 服務

在這個服務上右擊,選擇「Add Deployment」

在新打開的對話框中,有一個Project項,選擇要部署的項目

點擊「Finish」完成部署

這樣項目就部署到Tomcat裏面去了

jsp文件用IE打開出現的是源代碼?

JSP文件打開是需要部署到服務器端的,如tomcat

直接放到Webapps目錄下就可以了,步驟如下:

Tomcat的Webapps目錄是Tomcat默認的應用目錄,務器啟動時,會加載所有這個目錄 下的應用。

也可以將JSP程序打包成一個war包放在目錄下,服務器會自動解開這個war包,並在這個目錄下生成一個同名的文件夾。

一個war包就是有特 性格式的jar包,它是將一個Web程序的所有內容進行壓縮得到。

在程序執行中打包:

try{

string strjavahome = system.getproperty(“java.home”);

strjavahome = strjavahome.substring(0,strjavahome.lastindexof(\\))+”\\bin\\”;

runtime.getruntime().exec(“cmd /c start “+strjavahome+”jar cvf hello.war c:\\tomcat5.0\\webapps\\root\\*”);

}

catch(exception e){system.out.println(e);}

webapps這個默認的應用目錄也是可以改變。

打開Tomcat的conf目錄下的server.xml文件,找到下面內容即可:

Host name=”localhost” debug=”0″ appBase=”webapps” unpackWARs=”true” autoDeloy=”true” xmlValidation=”falase” xmlNamespaceAware=”false”

jsp登陸界面源代碼

1、login.jsp文件

%@ page language=”java” contentType=”text/html; charset=GB18030″

pageEncoding=”GB18030″%

%@ page import=”java.util.*” %

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

html

head

title登錄頁面/title

/head

body

form name=”loginForm” method=”post” action=”judgeUser.jsp”

table

tr

td用戶名:input type=”text” name=”userName” id=”userName”/td

/tr

tr

td密碼:input type=”password” name=”password” id=”password”/td

/tr

tr

tdinput type=”submit” value=”登錄” style=”background-color:pink” input

type=”reset” value=”重置” style=”background-color:red”/td

/tr

/table

/form

/body

/html

2、judge.jsp文件

%@ page language=”java” contentType=”text/html; charset=GB18030″

pageEncoding=”GB18030″%

%@ page import=”java.util.*” %

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

html

head

title身份驗證/title

/head

body

%

request.setCharacterEncoding(“GB18030”);

String name = request.getParameter(“userName”);

String password = request.getParameter(“password”);

if(name.equals(“abc”) password.equals(“123”)) {

3、afterLogin.jsp文件

%

jsp:forward page=”afterLogin.jsp”

jsp:param name=”userName” value=”%=name%”/

/jsp:forward

%

}

else {

%

jsp:forward page=”login.jsp”/

%

}

%

/body

/html

%@ page language=”java” contentType=”text/html; charset=GB18030″

pageEncoding=”GB18030″%

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

html

head

title登錄成功/title

/head

body

%

request.setCharacterEncoding(“GB18030”);

String name = request.getParameter(“userName”);

out.println(“歡迎你:” + name);

%

/body

/html

擴展資料:

java web登錄界面源代碼:

1、Data_uil.java文件

import java.sql.*;

public class Data_uil

{

public  Connection getConnection()

{

try{

Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user=”***”;

String password=”***”;

String url=”jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***”;

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public  String selectPassword(String username)

{

Connection connection=getConnection();

String sql=”select *from login where username=?”;

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);

result=preparedStatement.executeQuery();//可執行的     查詢

if(result.next())

password=result.getString(“password”);

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println(“找到的數據庫密碼為:”+password);

return password; 

}

public  void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

%@ page language=”java” contentType=”text/html; charset=utf-8″

pageEncoding=”utf-8″%

!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “”

html

head

meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″

title驗證用戶密碼/title

/head

body

jsp:useBean id=”util” class=”util.Data_uil” scope=”page” /

%

String username=(String)request.getParameter(“username”);

String password=(String)request.getParameter(“password”);

if(username==null||””.equals(username))

{

out.print(“script language=’javaScript’ alert(‘用戶名不能為空’);/script”);

response.setHeader(“refresh”, “0;url=user_login.jsp”);

}

else

{

System.out.println(“輸入的用戶名:”+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println(“密碼:”+passwordInDataBase);

if(passwordInDataBase==null||””.equals(passwordInDataBase))

{

out.print(“script language=’javaScript’ alert(‘用戶名不存在’);/script”);

response.setHeader(“refresh”, “0;url=user_login.jsp”);

}

else if(passwordInDataBase.equals(password))

{

out.print(“script language=’javaScript’ alert(‘登錄成功’);/script”);

response.setHeader(“refresh”, “0;url=loginSucces.jsp”);

}

else

{

out.print(“script language=’javaScript’ alert(‘密碼錯誤’);/script”);

response.setHeader(“refresh”, “0;url=user_login.jsp”);

}

}

%

/body

/html

3、loginSucces.jsp文件

%@ page language=”java” contentType=”text/html; charset=utf-8″

pageEncoding=”utf-8″%

!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “”

html

head

meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″

titleInsert title here/title

/head

body

hr size=”10″ width=”26%” align=”left” color=”green”

font size=”6″ color=”red” 登錄成功 /font

hr size=”10″ width=”26%” align=”left” color=”green”

/body

/html

4、user_login.jsp文件

%@ page language=”java” contentType=”text/html; charset=utf-8″

pageEncoding=”utf-8″%

!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “”

html

head

meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″

title登錄界面/title

/head

body  background=”C:\Users\win8\workspace\Login\image\9dcbdc339e72a5663b5c289fb5573c13_10.jpg”

center

brbrbrbrbrbr

h1 style=”color:yellow”Login/h1

br

form name=”loginForm” action=”login_check.jsp” method=”post” 

table Border=”0″

tr

td賬號/td

tdinput type=”text” name=”username”/td

/tr

tr

td密碼/td

tdinput type=”password” name=”password”

/td

/tr

/table

br

input type=”submit” value=”登錄” style=”color:#BC8F8F”

/form

/center

/body

/html

使用Servelet和JSP技術的應用系統綜合實例源代碼

它實現了Html語法中的java擴展(以 %,

%形式)。JSP與Servlet一樣,是在服務器端執行的。通常返回給客戶端的就是一個HTML文本,因此客戶端只要有瀏覽器就能瀏覽。

JSP技術使用Java編程語言編寫類XML的tags和scriptlets,來封裝產生動態網頁的處理邏輯。網頁還能通過tags和scriptlets訪問存在於服務端的資源的應用邏輯。JSP將網頁邏輯與網頁設計的顯示分離,支持可重用的基於組件的設計,使基於Web的應用程序的開發變得迅速和容易。

JSP(JavaServer Pages)是一種動態頁面技術,它的主要目的是將表示邏輯從Servlet中分離出來

jsp 是屬於客戶端還是服務端

JSP技術屬於客戶端技術,只不過他可以封裝處理邏輯,能讓處理邏輯和網頁設計分離,這就是你看到的源碼不一致的現象,但是這依然屬於客戶端技術

原創文章,作者:IADQ,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/143587.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
IADQ的頭像IADQ
上一篇 2024-10-22 23:34
下一篇 2024-10-22 23:34

相關推薦

  • 雲智直聘 源碼分析

    本文將會對雲智直聘的源碼進行分析,包括前端頁面和後端代碼,幫助讀者了解其架構、技術實現以及對一些常見的問題進行解決。通過本文的閱讀,讀者將會了解到雲智直聘的特點、優勢以及不足之處,…

    編程 2025-04-29
  • Python網站源碼解析

    本文將從多個方面對Python網站源碼進行詳細解析,包括搭建網站、數據處理、安全性等內容。 一、搭建網站 Python是一種高級編程語言,適用於多種領域。它也可以用於搭建網站。最常…

    編程 2025-04-28
  • Python調用crt telnet客戶端的實現

    本篇文章將詳細介紹如何使用Python調用crt telnet客戶端。我們將從以下幾個方面進行闡述: 一、安裝crt telnet客戶端 首先,我們需要下載並安裝crt telne…

    編程 2025-04-28
  • 源碼是什麼

    源碼是一段計算機程序的原始代碼,它是程序員所編寫的可讀性高、理解性強的文本。在計算機中,源碼是指編寫的程序代碼,這些代碼按照一定規則排列,被計算機識別並執行。 一、源碼的組成 源碼…

    編程 2025-04-27
  • 跨域通信浮標——實現客戶端之間的跨域通信

    本文將介紹跨域通信浮標的使用方法,該浮標可以實現客戶端之間的跨域通信,解決了瀏覽器同源策略的限制,讓開發者能夠更加方便地進行跨域通信。 一、浮標的原理 跨域通信浮標的原理是基於浮動…

    編程 2025-04-27
  • Go源碼閱讀

    Go語言是Google推出的一門靜態類型、編譯型、並髮型、語法簡單的編程語言。它因具有簡潔高效,內置GC等優秀特性,被越來越多的開發者所鍾愛。在這篇文章中,我們將介紹如何從多個方面…

    編程 2025-04-27
  • Python服務器客戶端

    本文將從以下幾個方面對Python服務器客戶端進行詳細闡述:socket編程、HTTP協議、Web框架、異步IO。 一、socket編程 Python的socket模塊是為網絡編程…

    編程 2025-04-27
  • C# Socket關閉後客戶端仍可連接的解決方法

    對於C# Socket通信中的一些問題,多數人可能已經熟知,但是有些問題仍然困擾着一部分人,例如Socket關閉後,客戶端仍然可以連接。本篇文章將在此問題為中心,圍繞該問題的原因和…

    編程 2025-04-27
  • Python怎麼看源碼

    本文將從以下幾個方面詳細介紹Python如何看源碼,幫助讀者更好地了解Python。 一、查看Python版本 在查看Python源碼之前,首先需要確認Python版本。可以在命令…

    編程 2025-04-27
  • 源碼審計面試題用法介紹

    在進行源碼審計面試時,可能會遇到各種類型的問題,本文將以實例為基礎,從多個方面對源碼審計面試題進行詳細闡述。 一、SQL注入 SQL注入是常見的一種攻擊方式,攻擊者通過在輸入的參數…

    編程 2025-04-27

發表回復

登錄後才能評論