JSP——内置对象application out session request response+EL+uplaod+download

JSP——内置对象application out session  request response+EL+uplaod+download

JSP内置对象application  out  session   request    response

<%=pageContext.getPage().toString() %>

   <%=pageContext.getOut() %>

   
  
   
    <%=pageContext.setAttribute("", "") %>

        <%=page.toString() %>

        
    <%=request.setAttribute("", "") %>

    <%=response.sendRedirect("") %>

    <%=session.setAttribute("", "") %>

    <%=application.setAttribute("", "") %>

    <%=out.print("") %>

    
    <%=config.getInitParameter("") %>
    
    <%=pageContext.getException() %>

    
    
   <%=exception %> 




JSP——内置对象application out session request response+EL+uplaod+download_第1张图片
JSP——内置对象application out session request response+EL+uplaod+download_第2张图片

JSTL  EL

EL ExpressionLanguage (表达式语言)

 

功能:代替js中的复杂语言


JSP——内置对象application out session request response+EL+uplaod+download_第3张图片
JSP——内置对象application out session request response+EL+uplaod+download_第4张图片
JSP——内置对象application out session request response+EL+uplaod+download_第5张图片
JSP——内置对象application out session request response+EL+uplaod+download_第6张图片


<%@page import="com.jredu.session.entity.User"%>
<%@ page language="java" import="java.util.*" 

pageEncoding="utf-8"%>
<%@ page  isELIgnored="false" isErrorPage="true"%>
<%


String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setCharacterEncoding("utf-8");
/* String c1= request.getParameter("c1"); */
request.setAttribute("c5","zhang");
List list=new ArrayList();
User user=new User("诸葛亮1","3333");
list.add(user);
     user=new User("诸葛亮2","3333");
     list.add(user);
   Map map=new HashMap();
   map.put("n316","张宇峰");
  request.setAttribute("n316map",map); 
session.setAttribute("sessss", list);     
session.setAttribute("sesss", user);
session.setAttribute("sess", "我是一个session对话");
application.setAttribute("app", "我是一个全局变量application");

%>



  
    
    
    My JSP 'show.jsp' starting page
    
	
	
	    
	
	
	

  
  
  
  <%-- <%=c1 %>  --%>
  ${param.c1}
  ${requestScope.c5}
  ${sessionScope.sess}
  ${applicationScope.app} 
   ${sessionScope.sesss.name}
      ${sessionScope.sessss[1].name}
      
        ${requestScope.n316map.n316}
         ${requestScope.n316map["n316"]}
         
        <%=exception %> 
        
  

uplaod+download



JSP——内置对象application out session request response+EL+uplaod+download_第7张图片

<%@ page language="java" import="java.util.*"

 pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



  
    
    
    My JSP 'chooseFile.jsp' starting page
    
	
	
	    
	
	
	

  
  
  
 





<%@page import="com.jspsmart.upload.Request"%>
<%@page import="com.jspsmart.upload.SmartUpload"%>
<%@page import="com.jspsmart.upload.File"%>
<%@ page language="java" import="java.util.*" 
pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";





/* SmartUpload su=new SmartUpload();
su.initialize(pageContext);
su.upload();
su.save("zyfupload");
com.jspsmart.upload.File file=su.getFiles().getFile(0);
String filepath="zyfupload\\";
filepath+=file.getFieldName();
//文件另存为
file.saveAs(filepath, SmartUpload.SAVE_VIRTUAL);

 */
SmartUpload su=new SmartUpload();
String  c1=null;

try{
su.initialize(pageContext);
//允许上传类型
su.setAllowedFilesList("gif,jpg,png,doc");
//不允许
su.setDeniedFilesList("jsp,asp,php,aspx,html,htm,exe,bat");
//单个文件的最大限度
su.setMaxFileSize(2000000000);
//所有上传文件的总限度
//su.setTotalMaxFileSize(5000000);
//执行上传
su.upload();

Request rq= su.getRequest();
  c1=rq.getParameter("c1");

su.save("zyfupload");
File file=su.getFiles().getFile(0);
file.saveAs("/zyfupload/"+file.getFileName(), su.SAVE_VIRTUAL);
 out.print(su.save("zyfupload")+"");
}catch(Exception e){
   out.print("上传格式不对");
}
%>



  
    
    
    My JSP 'upload.jsp' starting page
    
	
	
	    
	
	
	

  
  
  
 
<%=c1%>

<%@page import="com.jspsmart.upload.SmartUpload"%>
<%@ page language="java" import="java.util.*" 
pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";


String fileName=request.getParameter("fileName");
if(fileName!=null){

fileName=fileName.replaceAll(basePath, "");


SmartUpload su=new SmartUpload();
su.initialize(pageContext);

su.downloadFile(fileName);

}

%>



  
    
    
    My JSP 'download.jsp' starting page
    
	
	
	    
	
	
	

  
  
  
  








 

你可能感兴趣的:(Web前端,jsp学习专栏,session,download,对象,jsp,webview)