Apache Tomcat, Servlet, AJAX
2013-10-25 22:57
323 查看
Apache Tomcat
The Tomcat server does what a regular web server does while also providing an environment for running Servlets, such as JAVA classes, that can receive web requests and generate web responses.
Servlet variables
A servlet is instantiated by Tomcat once at the start of the web application. All incoming requests go to the same servlet. So some variables will take all requests the servlet has received.
Request/Response
The servlet is handed a HttpServletRequest and HttpServletResponse that are used to obtain information about the request and to send back to a response.
Parameters from the request can be accessed; and session information can be accessed.
Session information can be used to identify subsequent requests coming from the same user.
Response can have a variety of types including HTML, XML and JSON. A response may also be a redirection to something else.
AJAX
Asynchronous JavaScript with XML:
HTML or XHTML and CSS for presentation
DOM for dynamic display and interaction with data
XML for interchange of data: not required, could use JavaScript Object Notation (JSON), or simply pre-
formatted HTML or plain text
XSLT(Extensible Stylesheet Language Transformation) for manipulation and display of data: only used if using XML as well
XMLHttpRequest object for asynchronous communication
JavaScript (or VBScript) to combine all of above.
AJAX info
Ajax: A new approach to Web Application
XML Matters: Beyond the DOM
Ajax for Java developers: Build dynamic Java applications
Ajax for Java developers: Java object serialisation for Ajax
Synchronous vs Asynchronous
The classic (non-AJAX) model is synchronised with user activity, while AJAX model decouples user activity.
jQuery and JSON web request
The getJSON call is asynchronous; the callback is called when the valid response is received from the server. Be careful is generating more than one outstanding call at a time. If the response is not valid JSON then the callback
will not be called.
JSON at the servlet
The JSON request can be handled in the Servlet as a normal request.
The response is JSON formatted.
Drawbacks to AJAX
harder to develop than static pages
not automatically registered in browser history: there are workarounds such as changing the URL fragment
identifier(after the #)
makes it difficult to bookmark a state of the application
asynchronous behaviour not obvious to users
not as easy to access for web crawlers
incompatible browsers require fall-back to non-AJAX variation
cross domain access is currently restricted
may significantly increase number of requests to server.
The Tomcat server does what a regular web server does while also providing an environment for running Servlets, such as JAVA classes, that can receive web requests and generate web responses.
Servlet variables
A servlet is instantiated by Tomcat once at the start of the web application. All incoming requests go to the same servlet. So some variables will take all requests the servlet has received.
Request/Response
The servlet is handed a HttpServletRequest and HttpServletResponse that are used to obtain information about the request and to send back to a response.
Parameters from the request can be accessed; and session information can be accessed.
Session information can be used to identify subsequent requests coming from the same user.
Response can have a variety of types including HTML, XML and JSON. A response may also be a redirection to something else.
AJAX
Asynchronous JavaScript with XML:
HTML or XHTML and CSS for presentation
DOM for dynamic display and interaction with data
XML for interchange of data: not required, could use JavaScript Object Notation (JSON), or simply pre-
formatted HTML or plain text
XSLT(Extensible Stylesheet Language Transformation) for manipulation and display of data: only used if using XML as well
XMLHttpRequest object for asynchronous communication
JavaScript (or VBScript) to combine all of above.
AJAX info
Ajax: A new approach to Web Application
XML Matters: Beyond the DOM
Ajax for Java developers: Build dynamic Java applications
Ajax for Java developers: Java object serialisation for Ajax
Synchronous vs Asynchronous
The classic (non-AJAX) model is synchronised with user activity, while AJAX model decouples user activity.
jQuery and JSON web request
The getJSON call is asynchronous; the callback is called when the valid response is received from the server. Be careful is generating more than one outstanding call at a time. If the response is not valid JSON then the callback
will not be called.
JSON at the servlet
The JSON request can be handled in the Servlet as a normal request.
The response is JSON formatted.
Drawbacks to AJAX
harder to develop than static pages
not automatically registered in browser history: there are workarounds such as changing the URL fragment
identifier(after the #)
makes it difficult to bookmark a state of the application
asynchronous behaviour not obvious to users
not as easy to access for web crawlers
incompatible browsers require fall-back to non-AJAX variation
cross domain access is currently restricted
may significantly increase number of requests to server.
相关文章推荐
- Apache Tomcat, Servlet, AJAX
- AJAX POST请求中参数以form data和request payload形式在servlet中的获取方式
- Ajax请求Servlet返回文本 json html和XML数据并解析xml及responseText和responseXML的区别
- ajax功能1-servlet
- ajax与servlet利用json传送数据
- Ajax+Servlet、jsonp+Servlet、 jsonp+Struts2 实现跨域
- Ajax 异步处理 servlet 交互
- echarts通过ajax向服务器发送post请求,servlet从数据库读取数据并返回前端
- AJAX对于JAVA接收HttpServletRequest和json字符串两种方式的传递写法
- Ajax简单程序,使用ajax和servlet简单校验email地址
- java编程 Ajax+Servlet实例
- java痛苦学习之路[十二]JSON+ajax+Servlet JSON数据转换和传递
- ajax与servlet交互(通过JSON),JAVA的arraylist传到前端的方法
- 关于Ajax技术中servlet末尾的输出流
- ajax+servlet+mybatis 搭建网站
- 构建Apache Tomcat 6.0 Servlet/JSP 容器
- 基本的JSP中调用Ajax与Servlet进行数据交互
- 【Extjs登陆】表单ajax提交,登录实例 后台为servlet
- Servlet:htm+javascript+css+servlet (ajax)实现上传(能显示进度条)
- Ajax+Servlet实现无刷新下拉联动