react 前端框架如何驱动企业数字化转型与创新发展
942
2022-11-16
使用IDEA学习jsP代码第016课
new361.java
package pack03;import javax.servlet.RequestDispatcher;import javax.servlet.ServletConfig;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.javax.servlet.javax.servlet.javax.servlet.java.io.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;@WebServlet(name = "new361",urlPatterns = "/page04/new361")public class new361 extends HttpServlet{ @Override public void init(ServletConfig config) throws ServletException { super.init(config); try { Class.forName("com.mysql.jdbc.Driver"); } catch (Exception ignored) { } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); new354 login = (new354)session.getAttribute("login"); boolean ok = true; if(login == null) { ok = false; response.sendRedirect("new355.jsp"); } if(ok == true) { String loginName = login.getLoginName(); uploadFileMethod(request,response,loginName); } } private void uploadFileMethod(HttpServletRequest request, HttpServletResponse response, String loginName) { new358 upFile = new new358(); String backNews = ""; try { HttpSession session = request.getSession(true); request.setAttribute("upFile",upFile); String tempFileName = (String)session.getId(); File f1 = new File(tempFileName); FileOutputStream out = new FileOutputStream(f1); InputStream in = request.getInputStream(); byte[] b = new byte[10000]; int n; while ((n = in.read(b)) != -1) { out.write(b,0,n); } out.close(); in.close(); RandomAccessFile random = new RandomAccessFile(f1,"r"); int second = 1; String secondLine = null; while (second <= 2) { secondLine = random.readLine(); second++; } int position = secondLine.lastIndexOf("\\"); String fileName = secondLine.substring(position+1,secondLine.length()-1); byte[] cc = fileName.getBytes("ISO-8859-1"); fileName = new String(cc); fileName = fileName.replace(" ",""); String checkedStr = fileName.substring(0,fileName.indexOf(".")); boolean isLetterOrDigit = true; for (int i=0;i
new362.java
package pack03;//memberInformpublic class new362{ private String loginName; private String sex; private String email; private String phone; private String message; private int age; private String backNews; public String getLoginName() { return loginName; } public void setLoginName(String loginName) { this.loginName = loginName; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getBackNews() { return backNews; } public void setBackNews(String backNews) { this.backNews = backNews; }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~