At the morning meeting yesterday, the team lead suddenly asked me how to obtain the information in the client control in the background? I thought about it and replied: if form is used for overall submission, the content in the form is obtained using request in the C # code; if partial submission is used for JS interaction with Ajax, the open () and the send () method to the background, and the onreadystatechange () callback function of Ajax receives the data returned by the background.
When learning Java Web, I never fully understood how html and Servlet interact. Now I use a simple Servlet login instance to explain the interaction mechanism of the entire login process. Source code: http://pan.baidu.com/s/1ntcztbr.
Is the structure of the entire project.
Login.html is the logon page, and set the form processing class to LoginCheck (servlet) in the action attribute of the form table ). LoginCheck then calls Dao to access the SQL database (connect to the database through JDBC) and obtain the query result. The LoginCheck class selects a jump page (involving sendRedirect () redirects and getRequestDispatcher () Redirects Based on the returned results, as shown in blog: http://blog.csdn.net/lishehe/article/details/23133105 for details ).
The sparrow is small and dirty. Through this Demo, you can quickly learn Servlet.