样卷1编程.doc_第1页
样卷1编程.doc_第2页
样卷1编程.doc_第3页
样卷1编程.doc_第4页
样卷1编程.doc_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

编程1、 base href= My JSP 3_3.jsp starting page =60) RequestDispatcher s=request.getRequestDispatcher(good.jsp); s.forward(request,response); else RequestDispatcher s=request.getRequestDispatcher(bad.jsp); s.forward(request,response); % good.jsp base href= My JSP good.jsp starting page =85&i 你的得分是,优秀! 你的得分是,优秀!竟然满分,牛! =75) % 你的得分是,良好 =60) % 你的得分是,及格 bad.jsp base href= My JSP bad.jsp starting page 你的得分是,不及格,要努力了! 8.1文件下载first.javapackage download;import java.io.FileInputStream;import java.io.IOException;import .URLEncoder;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class first extends HttpServlet protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException this.doPost(req, resp); protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException req.setCharacterEncoding(utf-8); resp.setContentType(text/html;charset=utf-8); FileInputStream in=null; ServletOutputStream sos=null; String path=req.getParameter(path); int index=path.lastIndexOf(/); String filename=path.substring(index+1); String newName=URLEncoder.encode(filename,utf-8); String type=path.substring(path.lastIndexOf(.)+1); if(type.equals(doc) resp.setContentType(application/msword); else if(type.equals(pdf) resp.setContentType(application/pdf); elseresp.setContentType(application/vnd.ms-excel); resp.setHeader(content-disposition,attachment;filename=+newName); sos=resp.getOutputStream(); try in=new FileInputStream(path); int i=0; while(i=in.read()!=-1) sos.write(i); catch(Exception e) e.printStackTrace(); finally try sos.close(); in.close(); catch (IOException e) e.printStackTrace(); index.jsp base href= My JSP index.jsp starting page!- 文件下载 点击下载word文件 点击下载pdf文件 点击下载excel文件 web.xml first download.first first /down index.jsp 登陆9.1package first;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletConfig;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class first extends HttpServlet Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException / TODO Auto-generated method stubthis.doPost(req, resp);Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException / TODO Auto-generated method stubreq.setCharacterEncoding(utf-8);resp.setContentType(text/html;charset=utf-8);ServletConfig sc=this.getServletConfig();String ss=sc.getInitParameter(configString);PrintWriter pw=resp.getWriter();pw.println( +ss);pw.close(); index.jsp first first.first configString 输出一个字符串 first /kk 增删改index.jsp base href= My JSP index.jsp starting page!- #style-cfont-family: Lucida Sans Unicode, Lucida Grande, Sans-Serif;font-size: 12px;margin: 45px;width: 480px;text-align: center;border-collapse: collapse;border-top: 7px solid #9baff1;border-bottom: 7px solid #9baff1;#style-c thfont-size: 13px;font-weight: normal;padding: 8px;background: #e8edff;border-right: 1px solid #9baff1;border-left: 1px solid #9baff1;color: #039;#style-c tdpadding: 8px;background: #e8edff;border-right: 1px solid #aabcfe;border-left: 1px solid #aabcfe;color: #669; 学号院系性别年龄姓名操作 增加、a href=delete.jsp?sn=删除、a href=update.jsp?sno=&sdep=&ssex=&sage=&sname=修改 insert.jsp base href= My JSP index.jsp starting page!- 添加/修改信息 学号: 专业: 计算机科学系 外语系 化工系 机械工程系 性别:男 女 年龄: 姓名: update_date.jsp base href= My JSP update_data.jsp starting page!- update.jsp base h

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论