伏是什么意思| a-l-岩藻糖苷酶偏高是什么原因| 乳腺瘤是什么引起的| 左边偏头痛什么原因| 孽债是什么意思| 手作是什么意思| 印尼用什么货币| 冬枣什么时候上市| 你想干什么| 大学体检都检查什么| 汝字五行属什么| 花生什么时候收| 女金片的功效与作用是什么| 补脾吃什么好| vlone是什么牌子| 晕血是什么症状| 尿酸偏高是什么病| 商业保险报销需要什么材料| 大红袍属于什么茶| 化疗后恶心呕吐吃什么可以缓解| 锌中毒是什么症状| 上吐下泻吃什么食物好| 脚趾头疼是什么原因| 结局he是什么意思| 头晕是什么病| 什么的水花| 12.6是什么星座| 喝中药能吃什么水果| ny是什么牌子| 待字闺中是什么意思| 熊猫是什么科| 猪肝跟什么相克| 潋滟什么意思| ra是什么| 肠镜检查挂什么科室| 黄麻是什么| 绿本是什么| 口红用什么能洗掉| 什么是刑事拘留| 小肚鸡肠是什么意思| 子宫薄是什么原因造成的| 请问今晚买什么生肖| 九个月的宝宝吃什么辅食食谱| 手足口是什么病毒| 什么情况下喝补液盐| 不什么不| 牙虫是什么样的图片| 为什么吐后反而舒服了| dq什么意思| 铁观音属于什么茶类| red是什么颜色| 尿气味重是什么原因| 脸部浮肿是什么原因| 辛辣食物指的是什么| 独角戏什么意思| 宫颈多发纳囊是什么病| 鱼漂什么牌子的好| 读书有什么好处| 兴渠是什么菜| 为什么高考要体检| 李子和什么不能一起吃| 苏打水有什么作用| 舒五行属性是什么| 血糖高能喝什么粥| 商字五行属什么| 大佐相当于中国的什么军衔| 什么负什么名| 腔梗和脑梗有什么区别| 有口臭是什么原因引起的| 近亲为什么不能结婚| 为什么月经每个月提前| 点痦子去医院挂什么科| 消炎药不能和什么一起吃| 不怕流氓什么就怕流氓有文化| 1955年出生属什么| 一见倾心什么意思| 老凤祥银楼和老凤祥有什么区别| 7月16号是什么星座| 斜视手术有什么后遗症和风险| 食物中毒有什么症状| 举措前面搭配什么| cyan是什么颜色| 手热脚热是什么原因| 什么是预科生| 两肺纹理增多模糊是什么意思| on是什么牌子| 梦见出国了是什么意思| 五味杂陈什么意思| 功高震主是什么意思| 置之死地而后生是什么意思| 晚上喝柠檬水有什么好处| 躁郁症吃什么药| 凌晨四点醒是什么原因| 双眼屈光不正是什么意思| 病案首页是什么| 家里起火代表什么预兆| 关二爷是什么神| 四个月念什么字| 梦见考试是什么预兆| 阿胶不能和什么一起吃| 夜深人静是什么意思| 眼压高是什么症状| 月经期喝红糖水有什么好处| 素手是什么意思| 抖阴是什么| 通勤什么意思| 细菌性阴道炎用什么药好| 右眼老跳是什么原因| 手癣用什么药膏| 四个火念什么字| 10.25是什么星座| 什么饼不能吃脑筋急转弯| 得了阴虱用什么药能除根| 血糖高的人吃什么| ibs是什么单位| 虐猫是什么意思| 看对眼是什么意思| 脑血管堵塞会有什么后果| 液基薄层细胞学检查是什么| 迁单是什么意思| 93年什么命| 六味地黄丸起什么作用| 湿气重是什么原因引起的| 为什么会高血压| 今天什么地方地震了| 浅表性胃炎什么症状| 黄瓜敷脸有什么功效| 社保断了有什么影响| 性早熟有什么症状| 08年是什么年| 血管瘤是什么意思| 桉是什么意思| 什么时候补钙最佳时间| 挂匾是什么意思| 窦性心律不齐是什么情况| 有什么症状是肯定没怀孕| 桃子吃多了有什么坏处| 走资派是什么意思| 幼儿园转园需要什么手续| 1933年属什么生肖| 乡长是什么级别| uspa是什么牌子| 困是什么意思| 胃不消化吃什么药| 什么是信仰| 复机是什么意思| 扁食是什么| 甘胆酸是查什么的| 黑洞里面是什么| 本事是什么意思| 支气管炎吃什么药好得快| 离子水是什么水| 肺部结节吃什么药| 脑梗是什么意思| 地头蛇比喻什么样的人| 朱迅什么病| 巨蟹座女生喜欢什么样的男生| 梦见自己生了个儿子是什么意思| 五黄煞是什么意思| 痔疮为什么会出血| 黄明胶是什么| 头晕是什么原因| 首台套是什么意思| 有什么好吃的| dmd是什么意思| 画地为牢下一句是什么| 回奶吃什么药| 什么的灵魂| 司令是什么意思| 开飞机是什么意思| 今年是什么年| 李世民是什么民族| ast是什么| 单身为什么中指戴戒指| 菊花茶适合什么人喝| 送男生什么生日礼物| 坐小月子可以吃什么水果| 艾草泡脚有什么好处| 决明子配什么喝最减肥| 冷暖自知上一句是什么| biubiubiu是什么意思| 结节影是什么意思| 琼瑶剧是什么意思| 烤鸭为什么那么便宜| 代孕是什么意思| coolmax是什么面料| 窝沟封闭是什么| 什么叫西米| 吃什么可以消除淋巴结| 肩周炎有什么症状| 话糙理不糙是什么意思| 头疼应该挂什么科| 刚出生的小鱼苗吃什么| 办护照有什么要求| 冰粉的原材料是什么| 牙齿经常出血是什么原因| zn什么意思| 棉花糖是什么做的| hbv是什么| cdf是什么意思| 梦见骆驼是什么意思| 上眼皮痒是什么原因| 粤语点解什么意思| 银装素裹是什么意思| 热疹子是什么症状图片| 早些泄挂什么科| 红糖有什么功效| 指甲有白点是缺什么| 伤官女是什么意思| 线人是什么意思| 关节炎挂什么科| 感冒喉咙痒吃什么药| 苗侨伟为什么叫三哥| 手术后吃什么恢复快| 剪切是什么意思| 眼睛干涩吃什么中成药| amv是什么意思| 女人卵巢保养吃什么好| 肠炎吃什么| 肝内高回声结节是什么意思| 什么体质的人戴银变黑| 无机盐包括什么| 马和驴为什么能杂交| 性功能减退吃什么药| 地素女装属于什么档次| 血压高吃什么水果| 忌出火是什么意思| 例假颜色发黑是什么原因| 喉咙痛吃什么药效果好| reed是什么意思| 项羽字什么| 14数字代表什么意思| 疯狂动物城里的狐狸叫什么| 狐臭挂什么科| 心脏缺血吃什么补得快| 临床医学是什么| 吃了西瓜不能吃什么| 烤瓷牙和全瓷牙有什么区别| 肃穆是什么意思| 支原体是什么意思| phe是什么氨基酸| 为什么会经常流鼻血| 意外流产有什么症状| 生粉和淀粉有什么区别| 阻生智齿是什么意思| 何以是什么意思| 日安什么意思| 口周皮炎用什么药膏| 君山银针属于什么茶| 脑门疼是什么原因| 四季更迭是什么意思| 炒面用什么面条最好| 寻的部首是什么| 中元节是什么意思| 间接胆红素偏高什么意思| 打了鸡血是什么意思| 姨妈的老公叫什么| 开火车是什么意思| 宫寒吃什么好| 元首是什么意思| 生物钟什么意思| 胎盘长什么样子图片| 甲胎蛋白偏低说明什么| 痔瘘和痔疮有什么区别| 百度Jump to content

台湾被福布斯点名啦!上榜原因竟是“穷”

From Wikipedia, the free encyclopedia
(Redirected from JavaServer Pages)
JSP
Filename extension
.jsp, .jspx, .jspf
Internet media type
application/jsp[citation needed]
Developed byEclipse Foundation
Initial release1999; 26 years ago (1999)
Latest release
4.0
April 9, 2024; 15 months ago (2025-08-05)
Type of formatDynamic web page
StandardJSR 245
Open format?Yes
Websiteprojects.eclipse.org/projects/ee4j.jsp Edit this at Wikidata
百度 清新美丽,几乎就是一件兼具娱乐功能和自然景观的房间。

Jakarta Server Pages (JSP; formerly JavaServer Pages)[1] is a collection of technologies that helps software developers create dynamically generated web pages based on HTML, XML, SOAP, or other document types. Released in 1999 by Sun Microsystems,[2] JSP is similar to PHP and ASP, but uses the Java programming language.

To deploy and run Jakarta Server Pages, a compatible web server with a servlet container, such as Apache Tomcat or Jetty, is required.

Overview

[edit]
The JSP Model 2 architecture.

Architecturally, JSP may be viewed as a high-level abstraction of Jakarta Servlets. JSPs are translated into servlets at runtime, therefore JSP is a Servlet; each JSP servlet is cached and re-used until the original JSP is modified.[3]

Jakarta Server Pages can be used independently or as the view component of a server-side model–view–controller design, normally with JavaBeans as the model and Java servlets (or a framework such as Apache Struts) as the controller. This is a type of Model 2 architecture.[4]

JSP allows Java code and certain predefined actions to be interleaved with static web markup content, such as HTML. The resulting page is compiled and executed on the server to deliver a document. The compiled pages, as well as any dependent Java libraries, contain Java bytecode rather than machine code. Like any other .jar or Java program, code must be executed within a Java virtual machine (JVM) that interacts with the server's host operating system to provide an abstract, platform-neutral environment.

JSPs are usually used to deliver HTML and XML documents, but through the use of OutputStream, they can deliver other types of data as well.[5]

The Web container creates JSP implicit objects like request, response, session, application, config, page, pageContext, out and exception. JSP Engine creates these objects during translation phase.

Syntax

[edit]

Directives, scriptlets, and expressions, declaration

[edit]

JSPs use several delimiters for scripting functions. The most basic is <% ... %>, which encloses a JSP scriptlet. A scriptlet is a fragment of Java code[6] that runs when the user requests the page.

Other common delimiters include <%= ... %> for expressions, where the scriptlet and delimiters are replaced with the result of evaluating the expression, and directives, denoted with <%@ ... %>.[6][7]

Java code is not required to be complete or self-contained within a single scriptlet block. It can straddle markup content, provided that the page as a whole is syntactically correct. For example, any Java if/for/while blocks opened in one scriptlet must be correctly closed in a later scriptlet for the page to successfully compile. This allows code to be intermingled and can result in poor programming practices.

Content that falls inside a split block of Java code (spanning multiple scriptlets) is subject to that code. Content inside an if block will only appear in the output when the if condition evaluates to true. Likewise, content inside a loop construct may appear multiple times in the output, depending upon how many times the loop body runs.

Example

[edit]

The following would be a valid for loop in a JSP page:

<p>Counting to three:</p>
<% for (int i=1; i<4; i++) { %>
    <p>This number is <%= i %>.</p>
<% } %>
<p>OK.</p>

The output displayed in the user's web browser would be:

Counting to three:

This number is 1.

This number is 2.

This number is 3.

OK.

Standard JSP Tags

[edit]

The useBean Tag

[edit]

The JSP useBean tag enables the developer to access and create a Javabean.[8] Although using the useBean tag looks similar to an HTML tag, all JSP tags for JavaBeans use XML syntax. Therefore the code containing the useBean tag is case-sensitive.[9]

The useBean tag contains several attributes. The id attribute declares the name that is used for gaining access to the bean. The class attribute declares the package and class for the bean. The scope declares the object responsible for storing the bean. The value for the scope defines the duration for which the bean is available for the rest of the java application to use. The scope can be one of the following four values: [9]

  • The page scope implies that the bean is located in the implicitly defined PageContext object, and is only available for the current page. By default, all beans have a scope of page.
  • The request scope implies that the bean can be found in the HttpServletRequest object. This bean can be accessed by all other JSPs and servlets that have access to the current request object.
  • The session scope implies that the bean can be found in the HttpSession object. This bean can be accessed by all other JSPs and servlets that have access to the specified HttpSession object.
  • The application scope implies that the bean can be found in the ServletContext object. This bean can be accessed by all other JSPs and servlets that have access to the specified ServletContext object.

The getProperty and setProperty Tags

[edit]

After a bean has been created using the useBean tag, the getProperty and setProperty tags can be used for getting and setting the properties of the bean. The JSP getProperty is used to get the property of created bean. The JSP setProperty tag is used to set the properties for a bean. For the getProperty and setProperty tags, the name attribute is used to specify the bean's name. So the name attribute must match the id attribute provided by the useBean tag.[10]

Expression Language

[edit]

Version 2.0 of the JSP specification added support for the Expression Language (EL), used to access data and functions in Java objects. In JSP 2.1, it was folded into the Unified Expression Language, which is also used in JavaServer Faces.[11]

The JSP Expression Language uses a compact syntax which enables the developer to get attributes and JavaBean properties from a given request object. When using EL, a dollar sign ("$") must be added at the beginning of the code. The dollar symbol is followed by an opening brace ("{"), as well as a closing brace ("}"). The code is then written between the opening and closing braces.[12]

Example

[edit]

The following is an example of EL syntax:

The value of variable in the object javabean is ${javabean.variable}.

Additional tags

[edit]

The JSP syntax add additional tags, called JSP actions, to invoke built-in functionality.[7] Additionally, the technology allows for the creation of custom JSP tag libraries that act as extensions to the standard JSP syntax.[13] One such library is the JSTL.[14]

Jakarta Standard Tag Library

[edit]

Jakarta Standard Tag Library (JSTL) supports common tasks that must be performed in JSPs.[15] Examples includes iteration and conditionals (the equivalent of "for" and "if" statements in Java).[14]

Out of all the libraries in JSTL, the JSTL core library is most commonly used. A taglib directive must be used to specify the URI of the JSTL core library using a prefix. Although there are many different choices for the prefix, the "c" prefix is commonly used for this library.[16]

XML-compliant JSP

[edit]

JSP pages may also be written in fully valid XML syntax.[17] Such JSP files commonly use the alternative .jspx file extension, which usually causes the application server to validate the XML syntax.

Since the usual JSP syntax <% ... %> is not valid in XML, a developer must use alternative tags provided by JSP. For example, the common <%@ page .. %> directive may instead be written as a <jsp:directive.page .. /> tag, and tag libraries are imported using XML namespaces, instead of the usual <%@ taglib .. %> tag.

Compiler

[edit]

A JavaServer Pages compiler is a program that parses JSPs and transforms them into executable Java Servlets. A program of this type is usually embedded into the application server and run automatically the first time a JSP is accessed, but pages may also be precompiled for better performance, or compiled as a part of the build process to test for errors.[18]

Some JSP containers support configuring how often the container checks JSP file timestamps to see whether the page has changed. Typically, this timestamp would be set to a short interval (perhaps seconds) during software development, and a longer interval (perhaps minutes, or even never) for a deployed Web application.[19]

Criticism

[edit]

According to Joel Murach and Michael Urban, authors of the book "Murach's Java Servlets and JSP", embedding Java code in JSP is generally bad practice.[20] A better approach would be to migrate the back-end logic embedded in the JSP to the Java code in the Servlet.[20] In this scenario, the Servlet is responsible for processing, and the JSP is responsible for displaying the HTML,[20] maintaining a clear separation of concerns.

In 2000, Jason Hunter, author of "Java Servlet Programming" described a number of "problems" with JavaServer Pages.[21] Nevertheless, he wrote that while JSP may not be the "best solution for the Java Platform" it was the "Java solution that is most like the non-Java solution," by which he meant Microsoft's Active Server Pages. Later, he added a note to his site saying that JSP had improved since 2000, but also cited its competitors, Apache Velocity and Tea (template language).[21] Today, several alternatives and a number of JSP-oriented pages in larger web apps are considered to be technical debt.

See also

[edit]

Servlet containers

[edit]

Java-based template alternatives

[edit]

References

[edit]
  1. ^ Matthew Tyson (September 9, 2022). "What is JSP? Introduction to Jakarta Server Pages". InfoWorld. Retrieved May 30, 2024.
  2. ^ "FoRK Archive: Sun JSP 1.0 *not* available". www.xent.com.
  3. ^ The Life Cycle of a JSP Page (Sun documentation)
  4. ^ Seshadri, Govind (December 29, 1999). "Understanding JavaServer Pages Model 2 architecture". JavaWorld. Retrieved 2025-08-05.
  5. ^ "OutputStream already obtained (JSP forum at Coderanch)". coderanch.com.
  6. ^ a b Murach & Urban 2014, pp. 180–182, §2 Essential servlet and JSP skills - How to use JSP tags.
  7. ^ a b JSP 1.2 Syntax Reference
  8. ^ Murach & Urban 2014, pp. 198, §2 Essential servlet and JSP skills - Summary.
  9. ^ a b Murach & Urban 2014, pp. 186–187, §2 Essential servlet and JSP skills - How to code the useBean tag.
  10. ^ Murach & Urban 2014, pp. 188, §2 Essential servlet and JSP skills - How to code the getProperty and setProperty tags.
  11. ^ The Unified Expression Language (Sun Developer Network)
  12. ^ Murach & Urban 2014, pp. 176–177, §2 Essential servlet and JSP skills - How to use EL to get attributes and JavaBean properties.
  13. ^ Tag Libraries Tutorial - What is a Tag Library? (Sun) Archived April 19, 2012, at the Wayback Machine
  14. ^ a b "JavaServer Pages Standard Tag Library - The Java EE 5 Tutorial". docs.oracle.com.
  15. ^ Murach & Urban 2014, pp. 270–273, §2 Essential servlet and JSP skills -An Introduction to JSTL.
  16. ^ Murach & Urban 2014, pp. 178, §2 Essential servlet and JSP skills - How to enable the core JSTL library.
  17. ^ "The Java EE 5 Tutorial, Chapter 6 JavaServer Pages Documents". oracle.com. Retrieved 2025-08-05.
  18. ^ "IBM Docs". www.ibm.com.
  19. ^ "SyBooks Online". infocenter.sybase.com.
  20. ^ a b c Murach & Urban 2014, pp. 46–47, §1 Get started right - The JSP for the second page.
  21. ^ a b The Problems with JSP (January 25, 2000)

Works cited

[edit]

Further reading

[edit]
[edit]
归是什么意思 trust是什么意思 国家发改委主任什么级别 贤内助什么意思 银壶一般什么价位
7月1日什么星座 钥字五行属什么 双顶径和头围有什么区别 维生素b5药店叫什么 伴侣是什么意思
腰间盘膨出和突出有什么区别 吃什么水果对眼睛好 脚指甲变白是什么原因 瘪嘴是什么意思 支那是什么意思
女人脚抽筋是什么原因 舌头有点麻是什么病的前兆 豌豆有什么营养价值 focus什么意思 梦见病人好了什么预兆
人吸了甲醛有什么症状imcecn.com 女人能日到什么时候hcv8jop2ns7r.cn 腺样体肥大是什么症状hcv9jop3ns8r.cn 胃酸胃胀吃什么药hcv9jop3ns8r.cn 什么药补肾壮阳hcv7jop9ns1r.cn
晒背什么时候最佳时间hcv7jop9ns2r.cn 朱元璋为什么不杀汤和cj623037.com spiderking是什么牌子hcv9jop2ns3r.cn 流鼻血是什么病的前兆jiuxinfghf.com 开路是什么意思hcv7jop5ns4r.cn
梦见跟别人打架是什么意思hcv8jop5ns9r.cn 巴士是什么意思1949doufunao.com tmd是什么意思hcv7jop6ns9r.cn 8.3是什么星座hcv9jop6ns8r.cn 淋巴排毒是什么意思hcv8jop8ns2r.cn
家里有蜈蚣是什么原因hcv8jop7ns8r.cn hp阳性是什么意思hcv7jop7ns2r.cn hla一b27阳性是什么意思hcv8jop9ns5r.cn 佝偻是什么意思hcv9jop3ns7r.cn 苦涩是什么意思hcv8jop5ns3r.cn
百度