Java实验Word格式.docx
- 文档编号:8002498
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:41
- 大小:23.26KB
Java实验Word格式.docx
《Java实验Word格式.docx》由会员分享,可在线阅读,更多相关《Java实验Word格式.docx(41页珍藏版)》请在冰点文库上搜索。
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException{
response.setContentType("
text/html;
charset=gb2312"
);
Stringusername=newString(request.getParameter("
).getBytes("
iso-8859-1"
),"
gb2312"
Stringpassword=request.getParameter("
userUser=newuser();
PrintWriterout=response.getWriter();
if(username=="
"
||password=="
)
out.println("
TheusernameandthepasswordwouldnotbeNull!
else{
if((username.equals(User.user1))||username.equals(User.user2))
if((password.equals(User.password1)&
&
username.equals(User.user1))
||(password.equals(User.password2)&
username.equals(User.user2)))
out.println("
Welcome!
else
YouarenottheVIP!
}
out.flush();
out.close();
}
实验二
(1)login.jsp:
html>
jsp/check.jsp"
<
<
用户名:
/>
密码:
Check.jsp:
%
if(username.equals("
张三"
))
if(password.equals("
1234"
)){
Welcom!
session.setAttribute("
"
response.sendRedirect("
final.jsp"
}
ThepasswordisError!
Error!
YouarenottheVIP"
%>
Final.jsp:
用户名为:
%out.println(session.getAttribute("
));
(2)login.jsp:
web_message/check.jsp"
昵称:
Message.jsp:
%if(session.getAttribute("
curUser"
)==null){%>
scriptlanguage="
javascript"
alert("
请先登录"
location.href='
login.jsp'
;
/script>
%}%>
jsp:
useBeanid="
myBulletin"
class="
bean.Bulletin"
scope="
application"
/>
bean.User"
session"
欢迎来到聊天室&
nbsp;
getPropertyproperty="
nickname"
tableborder="
1"
编号<
留言标题<
留言者昵称<
留言时间<
inti;
for(i=myBulletin.getMsg_lb();
i!
=myBulletin.getMsg_rb();
){%>
%=myBulletin.getMsg()[i].getId()%>
ahref="
web_message/showmessage.jsp?
id=<
%=myBulletin.getMsg()[i].getTitle()%>
/a>
%=myBulletin.getMsg()[i].getNickname()%>
%=myBulletin.getMsg()[i].getTime()%>
%//nextuser
i=i+1;
i=i%(myBulletin.getMax_msg_num());
/table>
web_message/addMessage.jsp"
发新留言<
Showmessage:
%intid=Integer.parseInt(request.getParameter("
id"
%>
h2>
留言内容<
/h2>
web_message/message.jsp"
返回列表<
标题<
%=myBulletin.getMsg()[id].getTitle()%>
时间<
%=myBulletin.getMsg()[id].getTime()%>
作者<
%=myBulletin.getMsg()[id].getNickname()%>
内容<
%=myBulletin.getMsg()[id].getContent()%>
Addmessage.jsp
添加留言<
web_message/insertMsg.jsp"
留言标题:
title"
留言内容:
textareacols="
40"
rows="
5"
content"
/textarea>
Message_bean.java
packagebean;
importjava.util.Date;
publicclassMessage{
publicMessage(){
publicMessage(intid,Stringtitle,Stringnickname,Stringcontent){
this.id=id;
this.title=title;
this.nickname=nickname;
this.content=content;
this.time=newDate().toString();
//编号、留言标题、留言者昵称、留言时间
privateintid;
privateStringtitle,nickname,content,time;
publicStringgetContent(){
returncontent;
publicvoidsetContent(Stringcontent){
publicintgetId(){
returnid;
publicvoidsetId(intid){
publicStringgetTitle(){
returntitle;
publicvoidsetTitle(Stringtitle){
publicStringgetNickname(){
returnnickname;
publicvoidsetNickname(Stringnickname){
publicStringgetTime(){
returntime;
publicvoidsetTime(Stringtime){
this.time=time;
}
(3)
Add.jsp:
/Try3/InsertServlet.java"
tablewidth="
390"
height="
242"
border="
cellpadding="
cellspacing="
<
trbgcolor=88eeff>
<
td>
商品编号:
NO"
trbgcolor=99ffbb>
商品名字:
Name"
商品单价:
Price"
生产厂商:
Factory"
align="
right"
InsertServlet.java:
packageOne;
importjava.io.IOException;
importjava.io.PrintWriter;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importjavax.servlet.http.HttpSession;
publicclassInsertServletextendsHttpServlet{
/**
*ThedoPostmethodoftheservlet.<
br>
*
*Thismethodiscalledwhenaformhasitstagvaluemethodequalstopost.
*
*@paramrequesttherequestsendbytheclienttotheserver
*@paramresponsetheresponsesendbytheservertotheclient
*@throwsServletExceptionifanerroroccurred
*@throwsIOExceptionifanerroroccurred
*/
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
HttpSessionsession=request.getSession();
Stringno=newString(request.getParameter("
//("
Stringprice=newString(request.getParameter("
Stringname=newString(request.getParameter("
Stringfactory=newString(request.getParameter("
session.setAttribute("
no);
price);
name);
factory);
response.sendRedirect("
addfinish.jsp"
Addfinish.jsp
%out.println("
您输入的信息为:
br/>
实验三
(1)
student.jsp
publicclassstudent{
privateStringstuNum;
privateStringstuName;
privateStringtelephone;
privateStringemail;
privateStringaddress;
privateStringpostCode;
publicStringgetStuNum(){
returnstuNum;
publicvoidsetStuNum(StringstuNum){
this.stuNum=stuNum;
publicStringgetStuName(){
returnstuName;
publicvoidsetStuName(StringstuName){
this.stuName=stuName;
publicStringgetTelephone(){
returntelephone;
publicvoidsetTelephone(Stringtelephone){
this.telephone=telephone;
publicStringgetEmail(){
returnemail;
publicvoidsetEmail(Stringemail){
this.email=email;
publicStringgetAddress(){
returnaddress;
publicvoidsetAddress(Stringaddress){
this.address=address;
publicStringgetPostCode(){
returnpostCode;
publicvoidsetPostCode(StringpostCode){
this.postCode=postCode;
Insert.java
publicclassInsertextendsHttpServlet{publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
charset=utf-8"
request.setCharacterEncoding("
utf-8"
studentstu1=newstudent();
stu1.setStuNum(request.getParameter("
stuNum"
stu1.setStuName(request.getParameter("
stuName"
stu1.setTelephone(request.getParameter("
telephone"
stu1.setAddress(request.getParameter("
address"
stu1.setEmail(request.getParameter("
email"
stu1.setPostCode(request.getParameter("
postCode"
intnum;
try{
num=Integer.parseInt(stu1.getStuNum().trim());
}catch(Exceptione){num=0;
System.out.print("
未输入学号!
StringsqlString=null;
//Sql语句
sqlString="
insert
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 实验