JSP Introduction
What are Java Server Pages?
JSP stands for Java Server Pages, which is a dynamic web page development technology. It uses JSP tags to insert Java code into HTML web pages. Tags usually start with <% and end with %>.
JSP is a kind of Java servlet, mainly used to implement the user interface part of Java web applications. Web developers write JSPs by combining HTML code, XHTML code, XML elements, and embedded JSP actions and commands.
JSP obtains user input data through web forms, accesses databases and other data sources, and then dynamically creates web pages.
JSP tags have a variety of functions, such as accessing databases, recording user selection information, and accessing JavaBeans components; they can also pass control information and share information between different web pages.
Why use JSP?
JSP programs have similar functions to CGI programs, but compared with CGI programs, JSP programs have the following advantages:
- Better performance, because JSP can dynamically embed elements directly in HTML web pages without separately referencing CGI files.
- The server invokes JSP files that have already been compiled, unlike CGI/Perl, which must first load an interpreter and the target script.
- JSP is based on the Java Servlet API, so JSP has access to various powerful enterprise-level Java APIs, including JDBC, JNDI, EJB, JAXP, and so on.
- JSP pages can be used together with servlets that handle business logic, a pattern supported by Java servlet template engines.
Finally, JSP is an integral part of Java EE, a complete enterprise-level application platform. This means JSP can implement the most complex applications in the simplest way.
Advantages of JSP
The following lists other benefits of using JSP:
- Compared with ASP: JSP has two major advantages. First, the dynamic parts are written in Java rather than VB or other MS-specific languages, making it more powerful and easier to use. Second, JSP is easily portable to non-MS platforms.
- Compared with pure servlets: JSP makes it very convenient to write or modify HTML web pages without having to deal with a large number of println statements.
- Compared with SSI: SSI cannot use form data or connect to databases.
- Compared with JavaScript: although JavaScript can dynamically generate HTML on the client side, it is difficult to interact with the server, so it cannot provide complex services such as accessing databases and image processing.
- Compared with static HTML: static HTML does not contain dynamic information.
What's next?
We will guide you step by step to set up the JSP runtime environment, which requires a certain foundation in Java.
If you have not learned Java yet, you can first study theJava tutorial。