




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 私下股权转让及企业并购后的整合与发展协议
- (正式版)DB65∕T 4385-2021 《荒漠灌溉区覆膜花生机械化生产技术规程》
- 高端装备制造基地厂房使用权转让及技术转移协议
- 物业权让与担保合同范本:工业地产权益让渡
- 章珊离婚协议书:财产分割与子女监护权清晰约定
- 《离婚协议书:农业合作社成员权益保护协议》
- 学校教育空调系统安装及节能管理劳务分包合同
- 网络安全科技公司股东间股权转让及保密合同
- 矿山空调设备安装与安全生产管理合同范本
- 双方自愿离婚后财产分配及子女监护权变更补充协议
- 网络交友新时代课件
- 电商直播行业合规性风险管控与流程优化报告
- 第08讲+建议信(复习课件)(全国适用)2026年高考英语一轮复习讲练测
- 政务大模型安全治理框架
- 生态视角下陕南乡村人居环境适老化设计初步研究
- “研一教”双驱:名师工作室促进区域青年教师专业发展的实践探索
- 手卫生及消毒隔离基本知识
- 2025四川能投合江电力有限公司员工招聘11人笔试备考题库及答案解析
- 江苏省徐州市2025年中考英语真题(含答案)
- 包钢招聘考试试题及答案
- 2025年上海市安全员-A证(企业主要负责人)考试题库及答案
评论
0/150
提交评论