⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 friendfile.jsp

📁 JAVA 开发的一个企业网站 JAVABEAN+JSP +ACCE
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.io.*" %>
<%@ page import="mfkvit.login" %>
<jsp:useBean id="login" class="mfkvit.login" scope="session">
</jsp:useBean>
<%
if(session.isNew()){response.sendRedirect("index.jsp");}
String success=login.getSuccess();
if(success==null){success="";}
if(!(success.equals("ok"))){response.sendRedirect("index.jsp");}
%>
<html>
<link href="c.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	background-image: url(bgtile.gif);
}
-->
</style><body>
   <p>
     <%    String tempfilename=(String)session.getId();
         
		 String path2=getServletContext().getRealPath("")+"/basic/ShangChuangImg";  
  
          File f1=new File(path2,tempfilename);
          int n;
          try
          {
              InputStream in=request.getInputStream();
              BufferedInputStream my_in=new BufferedInputStream(in);
              FileOutputStream fout=new FileOutputStream(f1);
              BufferedOutputStream my_out=new BufferedOutputStream(fout);
              byte[] b=new byte[10000];
              while((n=my_in.read(b))!=-1)
              {
                   my_out.write(b,0,n);
              }
              my_out.flush();
              my_out.close();
              fout.close();
              my_in.close();
              in.close();
             // out.print("图片上传成功!<br>");
          }
          catch(IOException e)
          {
              out.print("文件上传失败!");
          }
          
          try
          {   
              RandomAccessFile random1=new RandomAccessFile(f1,"r");
              random1.readLine();
              String filename=random1.readLine();
              byte[] b=filename.getBytes("ISO-8859-1");
              filename=new String(b);
              int pointer=filename.lastIndexOf('\\');
              filename=filename.substring(pointer+1,filename.length()-1);
              File f2=new File(path2,filename);
			  session.setAttribute("name",filename);
              RandomAccessFile random2=new RandomAccessFile(f2,"rw");
              random1.seek(0);
              for(int i=1; i<=4; i++)
              {
                   String tempstr=random1.readLine();
              }
              long startPoint=random1.getFilePointer();
              random1.seek(random1.length());
              long mark=random1.getFilePointer();
              int j=0;
              long endPoint=0;
              while((mark>=0)&&(j<=5))
              {
                   mark--;
                   random1.seek(mark);
                   n=random1.readByte();
                   if(n=='\n')
                   {
                         j++;
                         endPoint=random1.getFilePointer();
                   }
              }
              long length=endPoint-startPoint+1;
              int order=(int)(length/10000);
              int left=(int)(length%10000);
              byte[] c=new byte[10000];
              random1.seek(startPoint);
              for(int i=0; i<order; i++)
              {
                    random1.read(c);
                    random2.write(c);
              }
              random1.read(c,0,left);
              random2.write(c,0,left);
              random1.close();
              random2.close();
              f1.delete();
             //out.print("文件更新成功!");
			 // out.print(filename);
			session.setAttribute("Friendimg",filename);
		    response.sendRedirect("friend.jsp");
			
          }
          catch(Exception e)
          {
             // out.print("文件更新失败!");
			 
          }
		
	// response.setHeader("Refresh","2;url=http://localhost:8080/WebModule1/admin/cpxx.jsp");
	//显示图片:out.print("<img src=http://localhost:8080/WebModule1/en_b_6_46.jpg>");  
   %>
   </p>

</body>
</html>
              
              

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -