Hi This query is in addition to a query I had posted some time before. When a document [of a particular type - which follows a particular template] is edited and submitted, or newly created, I want to log the IP address of the user plus some of the values of certain fields in that form. One reply I got was to use servlet filters? I tried using servlet filters and I found that it is possible. My doubts are : Is Servlet filters the preferred way for doing what I require in XWiki? Is there any other ways to do the same in xwiki? If Servlet filter is the way, then is there any preferred way to use in xwiki? (What I did was to place the servlets in WEB_INF/classes folder and added the entry in web.xml.) Regards Roopesh
Hi All, (Many thanks for providing the XWIKI RC2 release) I have created a servlet which return an XML document. The servlet was placed in the WEB_INF/classes. So it work correctly but returns in some situation strange content. According to my tests, the servlet code is correct but the wrong content is maybe related to the cache. /First situation, the servlet:/ ---------------------------- - It open a connection to database (XWIKI databased) - The servlet receive a parameter which is the name of an existing XWiki document - It send a SQL request for retrieving the content of the specified document: select XWIKI_CONTENT FROM ...WHERE XWIKI_NAME = XXXX), XXXX = is the full name of a document. - According to the content of my XWiki database the SQL request return only one document. - Then it process the document and return an XML document *RESULT: * - I got a correct result = * <?xml version="1.0" encoding="UTF-8"?> + 'A'* (whether I refresh the content in the internet explorer the result is the same) (the XML header + the content) /Another situation: / ------------------ - It open a connection to database - The servlet receive a parameter which *is similar to *the name *of a set of *existing XWiki document - It send a SQL request for retrieving the content of these documents: select XWIKI_CONTENT FROM ...WHERE XWIKI_NAME *like "%YYYY%"*), YYYY is 'string' for retrieving a set of documents *- The result is one document which is correct result according to the content of my database* - It retrieve the content in an /*while** loop*/ - process the the content - return the XML document Here the is JAVA code: ResultSet st = .....; String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; while (st.next()){ content = content + processContent(st.getString(XWD_CONTENT)); } ... this.writeResponse(resp, content); // *content is an XML document* *** RESULT: - First content (in the explorer) = <?xml version="1.0" encoding="UTF-8"?> *A* (correct) - When I refresh the explorer = <?xml version="1.0" encoding="UTF-8"?> *A A * - I refresh again the explorer = <?xml version="1.0" encoding="UTF-8"?> *A A* *A* ... - N refresh = <?xml version="1.0" encoding="UTF-8"?> *A A* *A ...A (N times)* (where *A* is the same content as *the first situation*) The servlet was transformed to class with main method and it return correct result...!!! I have also made test under the last version 'XWIKI RC2' but got the same problem. Is it related to the cache memory? I spend two days trying to solve it but without success.... Any help will be deeply appreciated. Thanks in advance. Cheers ---------- Youcef Bey
With the caveat that, as only one member of the XWiki community and (not even a developer), I have no special authority to pronounce what is "the preferred way" for doing this, but as one who has implemented a servlet filter with XWiki I will give what I see as some of the major parameters of your decision. One major consideration is whether your logging depends on any XWiki context information, or only on the content of the form. The action servlet builds a great deal of context before actually paying attention to the form content. This, it turns out, is not difficult to duplicate, but you do have the risk that this will change with later versions. It's not clear to me whether it's intended to be an officially supported API, and thus guaranteed not to change; I can tell you that it does not appear to have changed between the 0.9.840 version and 1.0, because my servlet filter that does this works on both. Another important issue is whether you actually want this to happen before XWiki attempts to deal with the form entry. If the filter were to log data that would be invalidated if the request failed, you would then have to undo it, which would be harder (or impossible, depending on the logging mechanism), though logging the subsequent failure should be acceptable. If the HTTP requests and responses contain all the information you require, consider the AWStats package (http://awstats.sourceforge.net/). It provides a great deal of information merely by looking at HTTP server logs, and it may be easily extensible to handle forms data. Of course, being an open-source project, I know it's extensible; the question is how easily. brain[sic]
-----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Saturday, April 28, 2007 3:49 AM To: [email protected] Subject: [xwiki-users] On using servlet filters
Hi
This query is in addition to a query I had posted some time before.
When a document [of a particular type - which follows a particular template] is edited and submitted, or newly created, I want to log the IP address of the user plus some of the values of certain fields in that form.
One reply I got was to use servlet filters? I tried using servlet filters and I found that it is possible.
My doubts are :
Is Servlet filters the preferred way for doing what I require in XWiki? Is there any other ways to do the same in xwiki?
If Servlet filter is the way, then is there any preferred way to use in xwiki? (What I did was to place the servlets in WEB_INF/classes folder and added the entry in web.xml.)
Regards Roopesh
I would like to add that my need (an external authentication and auto-registration feature)required completion of its operation before XWiki received the request. If AWStats doesn't fill your need, there is also the XWiki notification interface, with which I am not yet familiar enough to describe it fully, but I believe that its rules are searched on every request, giving you the insertion point that you need as well as the full XWiki context that may also be required. brain[sic]
participants (3)
-
bey -
roopesh@digitalglue.in -
THOMAS, BRIAN M (ATTSI)