I probably looked at Dwr's push mechanism, and my understanding is:Server state saved in ScriptsessionThe engine on the client page sends the request to the Web server periodically, see scriptsession, if found not to be empty, then send the JS call saved in Scriptsession to the client page, otherwise the thread waits for a certain time, but scriptsession is obtained by DWR the internal context object, which means that it cannot be changed beyond the
Ajax
The AJAX Framework Direct Web Remoting (DWR) project team recently announced the DWR 1.1 release.
DWR (Direct Web Remoting) is a WEB remote call framework that makes it easy to develop Ajax.
New features included in this new release include improved forms and forms of the DHTML Library (DWRUTIL), integrated struts, JSF, and beehive,
Example of combining DWR with spring
Applicationcontext. xml file
Java class
Package com. zscqj. Common;
Public class Hello {
Public String say (string INFOR ){Return "the message you sent is:" + infor;}}
JSP page:
String Path = request. getcontextpath ();String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";%>
Haha, no address! The basepath on this page is
The signatures section enables DWR to determine the Data Type stored in the collection. For example, in the following definition, we cannot know what type is stored in the list.
Public class Check{Public void setLotteryResults (List nos){...}} The signatures section allows us to imply what type DWR should use for processing. The format is easy for anyone who understands the generic type of JDK 5.
Import jav
1. Class
1.1 handle class
Package com. cloverworxs. uma. helper;
1.2 Bean class
Package com. cloverworxs. uma. helper;
2. Web. xml
3. DWR. xml
4. index. jsp
5. Use reverse Ajax from non-DWR servlet threads
List containers = containerutil. getallpublishedcontainers (getservletcontext ();
6. Notes
6.1 The required class library DWR. Jar commons-log
Okay, huh, cloud dizzy brain copy and paste so muchCode. Let's make a brief summary. Our small project involves the knowledge of extjs, JSON, DWR, spring, and hibernate components. It is not a task of learning to be proficient in every part of the project. Let's take a look at these framework technologies:
1. extjs is a very good Ajax framework that can be used to develop Ajax applications with rich clients with gorgeous appearances, making our B
Problem description:It is the simplest getting started demo of DWR. It is also written according to the Getting Started demo of DWR. However, the following problems occur during running.The session error dialog box is displayed on the front-end page.The console outputs:2007-5-29 11:58:53 org. directwebremoting. util. commonsloggingoutput ErrorSevere: A request has been denied as a potential csrf attack.Erro
, servletresponse res ){
Init ();
}
}
Import javax. servlet. genericservlet;
In the sessioncreated method, the ID of the current login user is put into the scriptsession. This ID is used to identify the push target during the subsequent push process.
Push method:
[Java]
View plaincopyprint?
/**
* Push to a specified user
* @ Param userid
* @ Param request
* @ Return
*/
Private void send (final string receiverid, final string MSG ){
Browser. withallsessionsfiltered (New scripts
We use DWR to invoke the remote method to involve the data conversion between JS and JAVA parameters and return values, for example:
The conversion between JS 123 and Java int or Integer, long
The conversion between JS "2009-06-23" and Java java.util.Date
Conversion between JS "[1,2,3]" and Java int[]
JS "{id:123, Name: ' Unmi '}" and Java Class person{int ID; Conversion between String name}
or more complex nested types ("{id:123, Name: ' Unmi ',
Util. js contains some useful function functions for calling on the client page. It can be separated from dwr and independent camp is used in your system.The main functions are as follows:1. Get the page parameter value by $ ()2. addOptions and removeAllOptions3. addRows and removeAllRows Filling Table4. getText: Get the text property value5. getValue: Get the form value6. getValues obtains multiple form values.7. onReturn8. selectRange9. setValue10.
DWR Full Name Direct WEB Remoting principle transforms Java code into JS object for cross-domain accessXml Dwr.xml packageorg.konghao.dwr.model;importjava.io.file;importjava.io.ioexception;import java.io.inputstream;importjava.util.arraylist;importjava.util.list;import javax.servlet.http.httpservletrequest;importorg.apache.commons.io.fileutils;import org.apache.commons.io.filenameutils;importorg.directwebremoting.webcontext;import Org.directwebrem
At the weekend, study dwr at home and do an example. Implements a message from the client to the server, after the message is returned, displayed on the client. The code is as follows:
JSP page:
String path = Request.getcontextpath ();String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%>
Haha, see the address is not AH. The basepath of this page is: Haha, see the address is not AH. The
getdata.jsp
In fact, the use of DWR to get background data is very easy to achieve, but for how to set the browser dynamic refresh Access data is not very clear, according to the information on the Internet to find that the original this is simpler:
function Myshow (){Timer = Window.setinterval ("GetResult ()", 2000);}
As a widely used WEB application development technology, AJAX firmly established its position, followed by some of the common Ajax usage patterns. For example, Ajax is often used to respond to user input and then modify part of the page with new data obtained from the server. However, sometimes the Web application's user interface needs to be updated to respond to asynchronous events that occur on the server side without requiring user action-for example, displaying new messages to an Ajax chat
Bkjia.com documentThis tutorial uses DWR (a Java Implementation of AJAX) as the page!
1. The following is the configuration of DWR.
(1) Configure DWRServlet in web. xml as follows:
Reference content is as follows:
(2) Configure in dwr. xml
Reference content is as follows:
2. Compile PageBean to store the data to be d
[Preface]
Read rich life and good code to share. I am aliman, and I look forward to communicating with you.
The following content is for the purpose of learning. The cover content is wide but not deep, and there may be some problems. Empty box.
[Hardware environment]
Ordinary PC, 4 GB memory, GB hard drive
[Operating system]
The following systems are virtual machines running on the same machine
Centos5.5-9 SVN server, release script
Centos5.5-4 jboss1
Centos5.5-5 JBoss 2 (tested but not enabl
The script engine. js contains the core part of DWR. Generally, your application should include it.Util. JS is usually included, which contains some optional practical methods.Demo. JS is dynamically defined in DWR. It also contains a corresponding remote version called demo. java. If you seeThe following code:Demo. Method1 = function {callback, P0}Demo. method2 = function {callback}So we can see that the f
DWR:
Direct Web remoting is an open-source Remote Server Ajax framework used to improve the interaction between web pages and Java. It can help developers develop websites that contain Ajax technology. It allows the code in the browser to use Java functions running on the Web server, just as it is in the browser.
Demo:
Pom. xml:
Web. xml:
DWR. xml
Userservice:
package com
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.