A little filter that detects if the The X-Forwarded-For (XFF) HTTP header is set.
If it’s set it means that the call arrived trough a proxy, and when the “getRemoteAddr()” method is called by the server it will return the last proxy in the IP array.
So basicly what this does is (if XFF is set) forces the “getRemoteAddr()/getRemoteHost()” methods to always return the first IP in the XFF header.
Here’s the filter class:
public final class EditHeader implements Filter {
private FilterConfig filterConfig;
public void init(FilterConfig filterConfig) throws
ServletException {
System.out.println("Filter initialized");
this.filterConfig = filterConfig;
}
public void destroy() {
System.out.println("Filter destroyed");
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
chain.doFilter( new MyWrapper((HttpServletRequest) request), response);
}
}
Here you have the filter wrapper class:
public final class MyWrapper extends
HttpServletRequestWrapper {
public HttpServletRequest httpRequest = (HttpServletRequest) super.getRequest();
public String reqAddr = httpRequest.getRemoteAddr();
public String reqHost = httpRequest.getRemoteHost();
public MyWrapper(HttpServletRequest servletRequest) {
super(servletRequest);
}
public String getRemoteAddr() {
String callerChain = httpRequest.getHeader("X-Forwarded-For");
if (callerChain==null ||callerChain.equals(""))
return reqAddr+"abc";
StringTokenizer tempStringTokenizer = new StringTokenizer(callerChain, ",");
return (tempStringTokenizer.nextToken());
}
public String getRemoteHost() {
String callerChain = httpRequest.getHeader("X-Forwarded-For");
if (callerChain==null ||callerChain.equals(""))
return reqHost+"def";
StringTokenizer tempStringTokenizer = new StringTokenizer(callerChain, ",");
return (tempStringTokenizer.nextToken());
}
And here’s a little test servlet :
public class test extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("“);
out.println(”Test“);
out.println(”“);
out.println(”Caller Host :” +req.getRemoteAddr() + ““);
out.println(”Caller Addr :” + req.getRemoteHost() +”“);
out.println(”“);
}
}
The web.xml looks like this :
EditHeader
EditHeader
EditHeader
test
test
test
test
test
Docs:
http://java.sun.com/products/servlet/Filters.html
http://www.onjava.com/pub/a/onjava/2004/03/03/filters.html
http://www.developer.com/java/ent/article.php/3467801
Drag&drop Tabs
Requests:
A dynamic user interface using the jQuery javascript library that allows an user to drag and drop a tab from one tab component to another.
Resources and online documentation used:
Time Management :
The order of events over the past days :
- Friday, May 30: 3 hours of reading/resource searching on JQuery.
- Saturday, May 31: 3-4 hours of tutorials and examples, experiencing with the JQuery UI.
- Sunday, June 1: 2 hours - putting together the interface.
The Interface :
The JQuery UI components used are:
The order of events managed:
- Create the two tab sets using JQuery’s tabs component.
- Make the tabs draggable with JQuery’s draggable component.
- Make the heads of the tab sets a “droppable” area so that it can recieve a new dragged element.
- On the “drop” event : Get the corespondent content of a dragged tab, remove drgged tab from the source tab set, add new tab into the destination tab set with a coresponding content identical to the one it came from
I used the “flora” theme found in the resources available in the JQuery documentation.
View the interface!
Main issues:
-didn’t figure out why the movement from the right set to the left one doesn’t work propperly
-didn’t manage to make the 2 containing divs display “on the same line” in IE6.. tried with a wrapper div but still not working
Before uploading files via a HTML-form, I want to do some client-side validating.
E.g. to check the filesize of the file selected by the user to upload.
Filesize should be, say, between 5MB and 50 MB. Javascript solution?!?
Nope, not really. By design, a person’s browser isn’t allowed to snoop around the file system.
….Googled it!
First atempt: Ended up here, tried [sourcecode language=’css’]…[/sourcecode] and got no result. (guess that this works only for wordpress.com users….no harm done)
At a second try: got a plugin here (syntaxhighlighter Google Code project by Alex Gorbatchev). Copied it to my server into the wp-content/plugins, activated it from the wp-admin and… that’s it. It works like this: Place your code on the page and surround it with < pre > tag. Set name attribute to code and class attribute to one of the language aliases you wish to use. Works for: XML/HTML, C++ (cpp, c, c++), C# (c#, c-sharp, csharp), CSS (css), Delphi/Pascal (delphi, pascal), Java (java), Java Script(js, jscript, javascript), PHP (php), Python (py, python), Ruby (rb, ruby, rails, ror) , Sql (sql), VB (vb, vb.net ).
After playing around a bit with the style my first try looked like this:
if($you_can_see_this)
echo "syntaxhighlighter works!";
So from now on i will post pieces of code that trigger my attention.
January 22nd 2008: W3C published a working draft for HTML 5. The HTML 5 working group includes AOL, Apple, Google, IBM, Microsoft, Mozilla, Nokia, Opera and many hundred other vendors.
Some of the new features in HTML 5 are functions for embedding audio, video and graphics, client-side data storage, and interactive documents. Other features are new page elements like <header>, <section>, <footer>, and <figure>.
HTML 5 improves interoperability and reduce development costs by making precise rules on how to handle all HTML elements, and how to recover from errors.
See full HTML 5 Reference
“Tick” not “thick”

” 4. The value chain will be replaced by the value constellation. (Many connections.)”
“Quit Talking, Begin Doing” - Walt Disney
P.s. Please note the tallent!
pp.s. Ps version wellcomed if offered 
ppp.s. the message is important not the looks 
pppp.s. [….] is sleeping