互联网开发技术第六讲Web技术.ppt

上传人:牧羊曲112 文档编号:6404973 上传时间:2023-10-27 格式:PPT 页数:33 大小:630.50KB
返回 下载 相关 举报
互联网开发技术第六讲Web技术.ppt_第1页
第1页 / 共33页
互联网开发技术第六讲Web技术.ppt_第2页
第2页 / 共33页
互联网开发技术第六讲Web技术.ppt_第3页
第3页 / 共33页
互联网开发技术第六讲Web技术.ppt_第4页
第4页 / 共33页
互联网开发技术第六讲Web技术.ppt_第5页
第5页 / 共33页
点击查看更多>>
资源描述

《互联网开发技术第六讲Web技术.ppt》由会员分享,可在线阅读,更多相关《互联网开发技术第六讲Web技术.ppt(33页珍藏版)》请在三一办公上搜索。

1、互联网开发技术Internet Systems Development Technologies,蔡 剑,Ph.D.Assistant Professor in Management Science and E-BusinessGuanghua School of ManagementPeking University,本讲内容,Web层技术(II)Servlet 的新功能JSP 技术About The Course Project:Proposal due one week after midtermSchedule meetings with groups next week About

2、The Midterm:Time:10/31(First 1.5 hours)Questions:choices,analysisCovers lecture 1-6(book p1-208),Review:J2EE Framework,Review:Servlet Process,Review:Collaboration,A Context is the Domain of An Application,Context,http:/yourip:8080/icamples/password,http:/yourip:8080/jsp-examples/*,Servlets Call Each

3、 Other,Get RequestDispatcher from HttpServletRequest:RequestDispatcher desp=req.getRequestDispatcher(“/target”)2.Get RequestDispatcher from ServletContext:ServletContext context=req.getSession().getServletContext()RequestDispatcher desp=context.getRequestDispatcher(“/target”)3.Get ServletContext for

4、 another application,then get RequestDispatcher:ServletContext context2=context.getContext(/icwork);RequestDispatcher desp=context2.getRequestDispatcher(“/target”);,To Load Another Servlet,despatcher.forward(req,resp);response.sendRedirect(targetURL);Difference?,HTTP/1.1 200 OK Content-Type:text/htm

5、l Transfer-Encoding:chunked Date:Thu,17 Oct 2002 20:42:53 GMT Server:Apache Coyote HTTP/1.1 Connector48f,HTTP/1.1 302 Moved Temporarily Content-Type:text/html Location:http:/Transfer-Encoding:chunked Date:Thu,17 Oct 2002 20:40:23 GMT Server:Apache Coyote HTTP/1.1 Connect2d8 Java Web Services Develop

6、er,Filters,Filter Functions,对网络请求进行分析,对输入数据进行预处理阻止请求和响应的进行根据功能改动请求的头信息和数据体.根据功能改动响应的头信息和数据体.和其他网络资源协作,Filter Chain,Filter Setup in Web.xml,filter.jpgSimpleFilterASimpleFilter The first filter samplejwadbook.SimpleFilter param1 value1SimpleFilter/path/index.jsp,Filter Example,P109,Filter to Check Pas

7、sword,Security Filter,Action Listener,serlvet的事件监听器接口能够处理ServletContext,HttpSession,ServletRequest的生命周期和属性变化事件,Data Base Connection,Database,SQL,Data resource,JDBC Connection,JDBC Connection,1.Use JDBC DriverPut driver.jar in/common/system/libClass.forName(“com.pointbase.jdbc.jdbcUniversalDriver”);2

8、.Make database connectionString pointbaseURL=jdbc:pointbase:server:/+host+/+databaseName;DriverManager.getConnection(pointbaseURL,username,password);,JDBC Connection(cont),3.Create SQL commandStatement stmt=connection.createStatement();String queryString=SELECT userid,lastname,addtime FROM Usertable

9、 ORDER BY userid;);ResultSet result=stmt.executeQuery(queryString);4.Analyze returned resultswhile(resultset.next()userID=resultset.getInt(userid);lastName=resultset.getString(lastname);addDate=resultset.getDate(addtime);5.Close database connectionconnection.close();,Connection Pool,Use Database Res

10、ources,1.Add JDBC driver2.Set server.xml(p160)3.Define database parameters DataSource reference to WorkflowAppDb defined in server.xml jdbc/WorkflowAppDb javax.sql.DataSource Container,Use Database Resources(cont),4.Use resource in ServletsDataSource dsource=(DataSource)ctx.lookup(java:comp/env/jdbc

11、/WorkflowAppDb);if(dsource!=null)Connection conn=dsource.getConnection();if(conn!=null)Statement stmt=conn.createStatement();ResultSet rst=stmt.executeQuery(select*from Concept order by ConceptID);,JSP Technologies,A Simple JSP,Method:URI:Protocol:,JSP Result,Implicit Objects,JSP Grammar,DirectivesI

12、nclude Directive Page Directive Taglib Directive Scripting ElementsDeclarations Expressions Scriptlet,JSP Grammar,Comments Actions,An Example of Directives,Include Date JSP The current date and time aredate.jsp:,An Example of Scripting Elements,Welcome!Good Morning!12)&(currenthour Good Afternoon!Go

13、od Evening!,An Example of Actions,Include Date JSP at Request TimeThe current date and time aredate2.jsp:Getting date.,Use JavaBeans with JSP,JSP handles the face.JavaBean handles the logic and complexity.,A Example of Using JavaBean,Use Bean in JSP to Calculate 你一般每天需要 卡能量,How to Write the JavaBean

14、,public class CalMeasure/properties defined public CalMeasure()public int getProperty()return this.proerty;public void setProperty(type value)this.property=value;Other method,Exercises 3,Programming:Create a database in pointbase,setup a table with the name,studentid,major,and contact of your group,display these contents with a servlet or jsp.(Extra credit:if user can modify the data-base information through a browser,I.E.add/update),

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号