Recent Notes

Displaying keyword search results 1 - 10
Created by Dr. Xi on April 29, 2013 09:00:48    Last update: April 29, 2013 09:00:48
In the case proposed by Diony , signing multiple elements by id, simply change the newSignedInfo to: // Create the SignedInfo final List transforms0... I must admit that I don't understand transformations, so take my example code with a grain of salt. Also, signing a doc fragment by PATH does not work, simply because there's no way to identify the fragment with a URI without referring to it by id. Reference ode from org.jcp.xml.dsig.internal.dom.DOMURIDereferencer : // Check if same-document URI and register...
Created by Dr. Xi on March 22, 2013 12:18:39    Last update: March 22, 2013 12:18:39
This is a step-by-step guide to create a "contract-first" web service with Apache CXF. It's a lot easier than doing the same thing with Spring-WS. The project uses standard Maven directory layout. Define the data types ( src/main/resources/hello.xsd ): <xs:schema xmlns:xs="http://www.w3.org/200... Define the service ( src/main/resources/hello.wsdl ): <?xml version='1.1' encoding='UTF-8'?> <wsdl:de... Create pom.xml : <project xmlns="http://maven.apache.org/POM/4.... Generate jaxb bindings: $ mvn generate-sources Code the web service ( src/main/java/com/example/cxfdemo/HelloPortImpl.java ): package com.example.cxfdemo; import javax.j... Declare the CXF servlet in web.xml ( src/main/webapp/WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Wire up the web service implementation ( src/main/webapp/WEB-INF/cxf-servlet.xml ): <?xml version="1.0" encoding="UTF-8"?> <beans x... Build the WAR: $ mvn clean package After the webapp is deployed (Tomcat running on port 8080), the web service (WSDL) is available via...
Created by Fang on March 30, 2012 10:07:25    Last update: March 08, 2013 13:41:57
After a user resets a password, I want to force the user to change the password before she gets access to secured content. This is usually done with a servlet filter. But with Spring MVC, you can also use a HandlerInterceptor . According to Spring JavaDoc: HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in contrast to the latter it just allows custom pre-processing with the option of prohibiting the execution of the handler itself, and custom post-processing. Filters are more powerful, for example they allow for exchanging the request and response objects that are handed down the chain. Note that a filter gets configured in web.xml, a HandlerInterceptor in the application context. As a basic guideline, fine-grained handler-related preprocessing tasks are candidates...
Created by Dr. Xi on March 01, 2013 16:09:00    Last update: March 04, 2013 12:28:23
This is probably the easiest way to create a web service in JAX-WS. There are no external dependencies other than Java EE. Assuming that you build the web service as a webapp (say jaxws-example.war), the pom.xml can be as simple as: <project xmlns="http://maven.apache.org/POM/4.0.0"... You can implement and deploy the web service in 3 easy steps: Code the service as a POJO (annotate class to expose it as a web service) package jaxws; import javax.jws.WebMethod; ... Declare the POJO as a servlet in WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... Build the webapp, and deploy the resulting war: mvn package The only catch is, this only works for a Java EE 5+ compliant container such as WebLogic or JBoss. It does not work for a simple servlet...
Created by Fang on July 25, 2012 12:59:47    Last update: July 25, 2012 12:59:47
Example code: import javax.xml.ws.BindingProvider; import jav... Wierdly, even though the response context ( ctx ) itself is a Map, you cannot iterate through the keys. This: for (String key: ctx.keySet()) { logger.inf... fails: WARN : InternalError - Handler execution resulted ...
Created by Fang on February 21, 2012 20:33:58    Last update: February 21, 2012 20:33:58
You can customize Tomcat error page with error code: <error-page> <error-code>404</error-code> ... or Java exception type: <error-page> <exception-type>java.lang.Throwab... Either error-code or exception-type is required, but not both. There's no way to aggregate error codes, such as: <!-- This does not work! --> <error-page> ... Customizing error pages is about the only way to suppress the default stack trace in Tomcat in case of an unhandled exception.
Created by Dr. Xi on February 01, 2012 12:55:28    Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this: <?xml version="1.0" encoding="UTF-8"?> <Context... which is equivalent to the following in web.xml : <env-entry> <env-entry-name>varName</env-entr... In Java code, the variable can be looked up like this: // import javax.naming.Context; // import javax...
Created by nogeek on November 03, 2010 20:52:49    Last update: November 23, 2011 08:54:44
My problem is simple: in my XML data, a timestamp is provided as a long integer (number of milliseconds since the "the epoch"). When I do XSLT, I want to display it as a readable string, such as "Mon Nov 01 18:08:48 CDT 2010". After hours of struggle, I found: It's not so easy to get the job done with JDK 1.6 There are tons of garbage on the web in this space (suggestions, code snippets that simply don't work) Simple Xalan extension functions was the only resource that's somewhat informative. Even there some of the examples don't work. Below is a list of what worked and what didn't. This works: <xsl:stylesheet version="1.0" xmlns:xsl="h... This does not (providing long value to Date constructor): <xsl:stylesheet version="1.0" xmlns:xsl="h......
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by Fang on September 07, 2009 20:44:15    Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app : <project> <modelVersion>4.0.0</modelVersion>... Create a directory named ear under javaee-app . Create pom.xml under ear : <project> <modelVersion>4.0.0</modelVersion>... Modify pom.xml in the webapp directory so that it looks like this: <project> <modelVersion>4.0.0</modelVersion> ... Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....
Previous  1 2 3 4 5 Next