Expression language-built-in objects

Source: Internet
Author: User

There are many built-in objects in an expression language.

PageContext, Pagescope,requestscope,sessionscope,applicationscope,param,paramvalues,header,headervalues,cookie, Initparam

<%@ page contenttype= "text/html" pageencoding= "GBK"%>    Pagecontext.setattribute ( "Info", "page attribute range");    Request.setattribute ("info", "Request attribute range");    Session.setattribute ("Info", "Session attribute range");    Application.setattribute ("info", "Application attribute range"); %>

In the different attribute ranges described above, the El's lookup range is page->request->session->application if the same name property is saved.

At this point, in order to accurately locate, you can rely on the built-in object help: Pagescope,requestscope,sessionscope,applicationscope

The above code can be changed to:

<%@ page contenttype= "text/html" pageencoding= "GBK"%>    Pagecontext.setattribute ( "Info", "page attribute range");    Request.setattribute ("info", "Request attribute range");    Session.setattribute ("Info", "Session attribute range");    Application.setattribute ("info", "Application attribute range"); %>

Through the El's built-in objects can also be found PageContext, before the time to explain the built-in objects, PageContext can get request,session,application and other objects, now you can directly through the El built-in object method call:

<%@ page contenttype= "text/html" pageencoding= "GBK"%> New}

The above naming and operation is to rely on the reflection mechanism to complete, is,get are automatically converted.

You can also receive parameters, pass parameters through URL rewriting, and if you want to receive parameters, complete the param parameter.

<%@ page contenttype= "text/html" pageencoding= "GBK"%>

When no arguments are passed, the first line shows NULL, and the second line shows a blank.

The first way to receive a parameter: URL rewrite: Http://localhost:8080/wly/eldemo/get_param_demo.jsp?ref=lixinghua

Pass parameters:

<HTML><HEAD><TITLE>WWW.MLDNJAVA.CN,MLDN High-end Java training </title>    Interests:    <input type= "checkbox" Name= "Inst" Value= "singing" > singing             <input type= "checkbox" Name= "Inst" value= "swimming" > swimming             <input type= " CheckBox "Name=" Inst "value=" reading "> reading             <input type=" Submit "value=" Show "></form></body >

Receive param_values_demo.jsp, need to use Paramvalues to receive a set of parameters, because now received is an array, you need subscript access:

<%@ page contenttype= "text/html" pageencoding= "GBK"%>//  Serious development, this code is implemented through the filter     request.setcharacterencoding ("GBK"); %>

In the actual development, the most used or Param object, receive a parameter. From the MVC pattern, all parameter reception should be cross-servlet.

Summarize:

1. El takes sequential mode output properties: Page<request<session<application, but avoids the existence of the same name attribute in general development

2. Receive $ (attribute) for parameters via param

Expression language-built-in objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.