jsp源码修改title的简单介绍

本文目录一览:

当修改JSP的源代码时,通过重新加载此JSP,通常可以在浏览器中看到这种修改。对于由JSP转化而来的SERVLET

因为当JSP加载的时候 web服务器会将其转换为对应的xx_jsp.java(原jsp文件名为 xx.jsp)类, 进行编译; 而你修改Servlet的时候需要将修改之后的Servlet上传到web服务器中去.情况就是这样.

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

jsp 中网站的首页源代码

这是最简单的一个例子,数据库要你自己建,用的是ACCESS

%@ page contentType=”text/html; charset=gb2312″ language=”java” import=”java.sql.*” errorPage=”” %

html

head

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

titleJSP连接Access数据库/title

style type=”text/css”

!–

.style1 {

font-size: 20px;

font-weight: bold;

}

/style

/headbody

div align=”center” class=”style1″JSP连接Access数据库/div

br

hr

p%

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); //载入驱动程序类别

Connection con = DriverManager.getConnection(“jdbc:odbc:jspdata”); //建立数据库链接,jspdata为ODBC数据源名称

//建立Statement对象

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSet rs = stmt.executeQuery(“select * from lyb”); //建立ResultSet(结果集)对象,并执行SQL语句

%

/p

p align=”center”NUMB1数据表中记录如下/p

table width=”640″ border=”1″ align=”center” bordercolor=”#7188e0″

tr bgcolor=”d1d1ff”

th width=”49″编号/th

th width=”90″姓名/th

th width=”126″E-mail/th

th width=”221″网站/th

th width=”80″QQ/th

/tr

%

while(rs.next())

{

%

tr bgcolor=”#f8f8f8″

th%= rs.getString(1) %/th

th%= rs.getString(2) %/th

th%= rs.getString(3) %/th

th bgcolor=”#f6f6f8″%= rs.getString(4) %/th

th%= rs.getString(5) %/th

/tr

%

}

rs.close();

stmt.close();

con.close();

%

/table

p align=”center”br

如果您能看到表格中的数据,说明连接数据库成功!/p

/body

/html

网上下的jsp源码要怎么用

需要部署到服务器中

找到菜单 window → Show View → Servers,打开Servers视图标签,部署的Tomcat 服务

在这个服务上右击,选择“Add Deployment”

在新打开的对话框中,有一个Project项,选择要部署的项目

点击“Finish”完成部署

这样项目就部署到Tomcat里面去了

怎样在修改JSP源代码后再应用到原网页上?服务器不是我这儿的 求教!!!

将修改后的jsp重新上传到服务器才可以得,否则无论如何也不会生效的。

jsp本身是运行在服务器容器中的,外部的修改是没有用的,只有更新服务器上面的那个源文件才可以。

另外,如果真的可以传到服务器上面的话,不用重启,会实时生效的。

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/244584.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2024-12-12 13:02
下一篇 2024-12-12 13:02

相关推荐

  • Python简单数学计算

    本文将从多个方面介绍Python的简单数学计算,包括基础运算符、函数、库以及实际应用场景。 一、基础运算符 Python提供了基础的算术运算符,包括加(+)、减(-)、乘(*)、除…

    编程 2025-04-29
  • Python满天星代码:让编程变得更加简单

    本文将从多个方面详细阐述Python满天星代码,为大家介绍它的优点以及如何在编程中使用。无论是刚刚接触编程还是资深程序员,都能从中获得一定的收获。 一、简介 Python满天星代码…

    编程 2025-04-29
  • 云智直聘 源码分析

    本文将会对云智直聘的源码进行分析,包括前端页面和后端代码,帮助读者了解其架构、技术实现以及对一些常见的问题进行解决。通过本文的阅读,读者将会了解到云智直聘的特点、优势以及不足之处,…

    编程 2025-04-29
  • Python海龟代码简单画图

    本文将介绍如何使用Python的海龟库进行简单画图,并提供相关示例代码。 一、基础用法 使用Python的海龟库,我们可以控制一个小海龟在窗口中移动,并利用它的“画笔”在窗口中绘制…

    编程 2025-04-29
  • Python樱花树代码简单

    本文将对Python樱花树代码进行详细的阐述和讲解,帮助读者更好地理解该代码的实现方法。 一、简介 樱花树是一种图形效果,它的实现方法比较简单。Python中可以通过turtle这…

    编程 2025-04-28
  • 用title和capitalize美观处理Python字符串

    在Python中,字符串是最常用的数据类型之一。对字符串的美观处理是我们在实际开发中经常需要的任务之一。Python内置了一些方法,如title和capitalize,可以帮助我们…

    编程 2025-04-28
  • Python大神作品:让编程变得更加简单

    Python作为一种高级的解释性编程语言,一直被广泛地运用于各个领域,从Web开发、游戏开发到人工智能,Python都扮演着重要的角色。Python的代码简洁明了,易于阅读和维护,…

    编程 2025-04-28
  • Python网站源码解析

    本文将从多个方面对Python网站源码进行详细解析,包括搭建网站、数据处理、安全性等内容。 一、搭建网站 Python是一种高级编程语言,适用于多种领域。它也可以用于搭建网站。最常…

    编程 2025-04-28
  • 用Python实现简单爬虫程序

    在当今时代,互联网上的信息量是爆炸式增长的,其中很多信息可以被利用。对于数据分析、数据挖掘或者其他一些需要大量数据的任务,我们可以使用爬虫技术从各个网站获取需要的信息。而Pytho…

    编程 2025-04-28
  • 源码是什么

    源码是一段计算机程序的原始代码,它是程序员所编写的可读性高、理解性强的文本。在计算机中,源码是指编写的程序代码,这些代码按照一定规则排列,被计算机识别并执行。 一、源码的组成 源码…

    编程 2025-04-27

发表回复

登录后才能评论