Recent Notes

Displaying keyword search results 1 - 8
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 freyo on June 09, 2011 15:52:12    Last update: June 09, 2011 15:52:30
Follow these steps to add a device administrator application to Android, i.e., make the application appear in the "Select device administrators" screen (Settings -> Location & Security -> Select device administrators): Add a receiver in AndroidManifest.xml : <receiver android:name="android.app.admin.DeviceAd... All elements and attributes listed above are needed. The attribute android:description must be a string resource, not a literal string. The meta-data element points to an XML resource. Create the meta-data resource res/xml/admin_app_resource.xml : <device-admin xmlns:android="http://schemas.androi... Define values for string resources ( res/values/strings.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc...
Created by Dr. Xi on March 28, 2011 20:51:30    Last update: March 28, 2011 20:53:46
HTTP basic authentication is just Base64 encoded user name and password passed in as the Authorization header. So the following code works: // encode user name and password String credent... However, since JDK 1.2, there's a more Java friendly way: Authenticator.setDefault(new Authenticator() { ... Test code: import java.net.*; import java.io.*; pub...
Created by voodoo on July 11, 2009 15:14:55    Last update: July 29, 2010 22:45:48
cURL is a command line tool for transferring files with URL syntax. The main purpose and use for cURL is to automate unattended file transfers or sequences of operations. It's really easy to see HTTP headers with curl: C:\>curl --head http://www.google.com HTTP/1.0 ... or, headers and page together (dump headers to stdout): $ curl --dump-header - http://www.google.com HTTP/... Download openssl from openssl.org: curl http://www.openssl.org/source/openssl-0.9.6m.... C:\>curl --help Usage: curl [options...] <url> ...
Created by voodoo on February 08, 2010 04:57:49    Last update: February 08, 2010 04:57:49
If you don't want to open an extra port for VNC or want extra security with SSH, you can setup an SSH tunnel for VNC. On Windows, you can do this with Putty or openssh . Open a command window, and enter (using Putty as example): C:\local\bin\plink.exe -ssh -2 -L localhost:5901:r... When connecting with vncviewer , use localhost:5901 as server instead of remote_host:5901 . If you use the setup frequently, it is more convenient to setup the tunnel as a Windows service . Assuming the name of the service is vnc_tunnel , the registry entry would look like: Windows Registry Editor Version 5.00 [HKEY_...
Created by Dr. Xi on October 23, 2008 03:54:04    Last update: October 23, 2008 03:57:44
Add validator plugin in struts-config.xml <struts-config> . . . ... Set validate="true" on action form <struts-config> <!-- ========== Form Bean De... Add validation rules in validation.xml <?xml version='1.0' encoding='windows-1252'?> <... If you override validate , make sure super.validate is called. package com.example; import javax.servlet.h... Read the documentation: http://struts.apache.org/1.2.4/userGuide/dev_validator.html
Created by Dr. Xi on October 08, 2008 19:33:21    Last update: October 08, 2008 20:17:42
In sqlnet.ora , there's a parameter named NAMES.DEFAULT_DOMAIN that usually contains the value world . If you remove this parameter then you don't need to append .world . My sqlnet.ora contains three lines: # sqlnet.ora Network Configuration File: C:\wo... To force a lookup without NAMES.DEFAULT_DOMAIN appended, append a dot to the tnsname: tnsping unqualified_tnsname_name.
Created by Dr. Xi on October 06, 2008 22:48:08    Last update: October 06, 2008 22:50:11
A first attempt would be to create an input file like this: userid password shell_command1 shell_... and feed the lines to the telnet client: cat telnet_input.txt | telnet remote_host #... However, you'll learn soon enough that it doesn't work. You get output like this: Trying 192.168.159.128... Connected to bash... What's happening? The telnet client depleted all input before the remote host had a chance to respond. Since there's no more input, the telnet client initiated to close the connection. Adding a delay between the commands makes it work: (echo userid sleep 10 echo password ... How much time to sleep between commands is just guesswork. You can use Expect to provide more control over the automated session: #!/usr/bin/expect # timeout script aft......