Apache Tomcat, Servlet, AJAX

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值