Java Web basics: Summary of Java Web Applications

Source: Internet
Author: User

 

Java Web application OverviewThe core technologies of Java Web applications include: u jsp, Basic Input and Output Methods, u JavaBean, processing of functions, and u servlet, which controls the application process; u jdbc is an indispensable technology for interacting with databases. U jstl and Expression Language El are used to control and output various information on JSP pages. JSP mainly provides input and output functions, including HTML code, client script (JavaScript, etc.), JSP labels and commands, and custom tag library. The following is a typical example of JSP: <% @ page contenttype = "text/html; charset = gb2312 "%> <% @ taglib prefix =" C "uri =" http://java.sun.com/jsp/jstl/core "prefix =" C "%> User information is as follows: <Table> <tr> <TH> user number </Th> <TH> User Name </Th> <TH> birthday </Th> </tr> <C: foreach items = "$ {userlist}" Var = "user"> <tr> <TD >$ {user. userid} </TD>

<TD> $ {user. username} </TD> <TD >$ {user. birthday }</TD> </tr> </C: foreach> </table>: <% @ page contenttype = "text/html; charset = gb2312 "%> <% @ taglib prefix =" C "uri =" http://java.sun.com/jsp/jstl/core "prefix =" C "%> these two lines are JSP command user information as follows: <Table> <tr> <TH> user number </Th> <TH> User Name </Th> <TH> birthday </Th> </tr> the above is the HTML code <c: foreach items = "$ {userlist}" Var = "user"> standard tag library tag <TD >$ {user. userid} </TD> <TD >$ {user. username} </TD> <TD >$ {use R. Birthday} </TD> the nested Expression Language JavaBean in HTML completes all the processing functions of the system. Javabean is a common Java class in Java, so there is no special place. In addition, Java Web provides multiple labels related to the JavaBean operation. Servlet technology, which can provide the same functions as JSP. However, unlike JSP, JSP exists in the form of a script file, while servlet exists in the form of a Java file. Therefore, servlet is also a Java class, which is a special Java class. In Java Web technology, it mainly implements control functions and coordinates the relationship between JSP pages and functional JavaBean. The following is a typical servlet example: Package servlets; import javax. servlet. *; import javax. servlet. HTTP. *; import Java. io. *; import beans. *; public class loginservlet extends httpservlet {// All servlets must inherit the httpservlet // main method public void doget (httpservletrequest request, httpservletresponse response) throws ioexception, servletexception {// obtain JSP page information and obtain the user ID and password string userid = request. getparameter ("userid"); string user Pass = request. getprameter ("userpass"); // create the model object userbean user = new userbean (); // call the business method to verify Boolean B = user. validate (userid, userpass); // file to be switched, select the response User Interface string forward; If (B) forward = "success. JSP "; else forward =" failure. JSP "; // response to the user requestdispatcher dispatcher = request. getrequestdispatcher (forward); dispatcher. forward (request, response) ;}} interaction with databases is indispensable for almost all Java Web applications, and may be related to various types of database management. Systems, but most of them are relational database management systems. Java provides the JDBC technology to complete the interaction between Java applications and various database systems. Although JDBC technology is not a Java Web technology, it is inevitable to use JDBC technology in Java Web technology. Therefore, JDBC is also one of the most important technologies in Java Web development. Jstl and Expression Language were introduced after jsp2.0 to facilitate the use of common functions on JSP pages. Typically, information is output, because the main function of the JSP interface is to display information. The expression language makes information display very simple. Like $ {user. userid} in the preceding JSP code, the complete function is to obtain the userid attribute of the user object from the request (described in later sections. If Java code is used, it is not that simple. In addition, jstl provides a large number of common functions, such as structure selection and loop structure. In the preceding JSP Example, the <C: foreach> label is used for loop control. Note: In the later part of this book, if there is no special description, all web applications represent Java Web applications. Last Lecture: Overview of Web ApplicationsNext Lecture: Fourth, the document structure of Java Web ApplicationsLi xucheng csdn blog: Why? U= 124362 & C = 7be8ba2b6f3b6cc5
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.