[JavaEE] Getting started with jsp, getting started with javaeejsp

Source: Internet
Author: User

[JavaEE] Getting started with jsp, getting started with javaeejsp

Servlet is good at writing java code, but it is very inconvenient to splice html.

JSP can nest java code in html, which makes it easier to display

 

Tomcat helps us translate jsp pages into Servlet for running and view the Directory

Tomcat directory \ work \ Catalina \ localhost \

Generate a Servlet File xxx_jsp.java. the jsp script snippets are placed in the _ jspService () method.

 

After creating a project using eclipse, modify the release path and directly release the project to the webapps directory of Tomcat,

In the Servers tab, delete the following items, right-click open, and select use Tomcat installation.

 

Jsp Declaration: <%! Several java code %>. The Code will be resolved to the member of the class.

Jsp comment: <% -- Comment content -- %>

Index. jsp

<% @ Page import = "org. apache. jasper. tagplugins. jstl. core. out "%> <% @ page import =" java. util. date "%> <% @ page language =" java "contentType =" text/html; charset = UTF-8 "pageEncoding =" UTF-8 "%> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> 

Index_jsp.java

Public final class index_jsp extends org. apache. jasper. runtime. httpJspBase implements org. apache. jasper. runtime. jspSourceDependent {public void test () {int a = 0;} public void _ jspService (final javax. servlet. http. httpServletRequest request, final javax. servlet. http. httpServletResponse response) throws java. io. IOException, javax. servlet. servletException {final javax. servlet. jsp. pageContext pageContex T; javax. servlet. http. httpSession session = null; final javax. servlet. servletContext application; final javax. servlet. servletConfig config; javax. servlet. jsp. jspWriter out = null; final java. lang. object page = this; javax. servlet. jsp. jspWriter _ jspx_out = null; javax. servlet. jsp. pageContext _ jspx_page_context = null; try {response. setContentType ("text/html; charset = UTF-8"); pageContext = _ jspxFac Invalid. getPageContext (this, request, response, null, true, 8192, true); _ jspx_page_context = pageContext; application = pageContext. getServletContext (); config = pageContext. getServletConfig (); session = pageContext. getSession (); out = pageContext. getOut (); _ jspx_out = out; out. write ("\ r \ n"); out. write ("\ r \ n"); out. write ("\ r \ n"); out. write ("<! DOCTYPE html PUBLIC \ "-// W3C // dtd html 4.01 Transitional // EN \" \ "http://www.w3.org/TR/html4/loose.dtd\"> \ r \ n "); out. write ("

 

 

Related Article

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.