3/9/2010

UTF-8 Encoding In POST And GET Request On Tomcat

Filed under: — Aviran Mordo

I recently had to write a project using Tomcat that takes data from html forms and save the data to a database. I thought hey this is pretty strait forward, however while I was expecting the form data to arrive to Tomcat as a UTF-8 string I surprisingly got the request encoding is ISO-8859-1.

While you think that browsers take hints from the page or form encoding and send form data back to the server in the same encoding, web servers remain unaware of the encoding scheme. They typically assume that the request encoding is ISO-8859-1.

So, if my application expects a UTF-8 encoded string, Tomcat assumes 8859-1. The result, of course, is that text data becomes mangled.

Looking for answers I found that I can specify URIEncoding=”UTF-8″ in Tomcat’s connector settings within the server.xml file. Now you might think, hey that’s pretty strait forward, well I thought so too, until I discovered that it only works for GET requests, and Tomcat ignores this setting for POST request.

Now my project had to deal with POST data, and also store the data into a database. So I kept looking until I found a solution. In order for your Servlet to process POST data at UTF-8 you need to explicitly set the character encoding in your Servlet, and to do that all you need to do is put this line in your doPost method (or just add a filter chain and add this line in the doFilter method

request.setCharacterEncoding("UTF-8")

Another trick to get UTF-8 in Tomcat is to tell the JVM to use UTF-8 as file encoding?

-Dfile.enconding=UTF-8

I know it seems strange that Tomcat does not have a configuration setting to handle UTF-8 encoding in POST request, but I could not find one. If you know of such configuration setting you are welcome to share this information in the comments.

1/5/2010

SpringSource takes Spring 3.0 to GA

Filed under: — Aviran Mordo

SpringSource announced that it has released Spring 3.0 for General Availability. Spring 3.0 features REST support, Spring expression language, extended support for annotation-based components, declarative model validation based on constraint annotations and standardized dependency injection annotations.

Spring 3.0 GA can be hosted on Java EE 6 servers. It supports JPA 2.0 final, JSR 303 validation mode and @Managed Bean (JSR-250 v1.1) annotation for component scanning.

Spring 3.0 brings new component model features. If you have a Spring-powered application, you can switch your libraries to Spring 3.0 without having to upgrade your server installation, according to the company.

11/6/2009

Google offers JavaScript programming tools

Filed under: — Aviran

With a project called Closure Tools, Google plans on Thursday to start helping developers who aspire to match the company’s proficiency in creating Web sites and Web applications.

Google is a strong proponent of using JavaScript to write Web-based programs, part of its Web-centric ethos. Indeed, the company has pushed the language to its limits with services such as Gmail and Google Docs, and it developed its Chrome browser in part to enable JavaScript programs to run faster.

But writing, debugging, and optimizing heavy-duty JavaScript can be difficult–in part because a given JavaScript program sometimes works differently on different browsers. Google’s open-source Closure Tools project is an attempt to help with some of these challenges.

10/18/2009

IntelliJ IDEA Goes Open-Sources

Filed under: — Aviran Mordo

JetBrains, the maker of the popular IntelliJ IDEA Java integrated development environment, plans to deliver an open-source version of its tool set.

JetBrains, the maker of the popular IntelliJ IDEA Java integrated development environment, has decided to deliver an open-source version of its tool set.

JetBrains on Oct. 15 announced a public preview of the free Community Edition of IntelliJ IDEA.

Moreover, “Starting with the upcoming Version 9.0, IntelliJ IDEA will be offered in two editions: Community Edition, [which will be] free and open source, and Ultimate Edition, which until today has been referred to as simply IntelliJ IDEA,” JetBrains said in a news release. The release continued:

“The brand-new Community Edition is built on the IntelliJ platform and includes its sources. JetBrains has made it as easy as possible to access and use the source code of the Community Edition and the IntelliJ platform, by applying the democratic Apache 2.0 license to both of them.”

Sergey Dmitriev, CEO of JetBrains, said in the release, “We’ve always been open to the community—with our public Early Access Program (EAP), issue trackers, forums and so on. This made for a tight and direct feedback loop with our users, even at a time when this wasn’t a widely accepted practice in the industry. Since then, we’ve supported hundreds of open-source projects with free product licenses, contributed code to various open-source projects like Groovy and Scala, and developed several open-sourced IntelliJ IDEA plug-ins ourselves. So, you can see how offering the IntelliJ IDEA experience for free, through an open-source license, goes hand in hand with our focus on the community. Open source has become the mainstream, and we continue to embrace it as an exciting challenge. In brief, we’re not changing direction—we’re moving forward.”

The JetBrains release described the Community Edition of IntelliJ as a good choice for developers “working on pure Java/Groovy applications, or doing Swing development.” This edition contains IntelliJ IDEA features such as “various refactorings and code inspections, coding assistance, debugging, TestNG and JUnit testing; CVS, Subversion and Git support, as well as Ant and Maven build integration.” It continued, “To learn more and download the Community Edition Public Preview, please visit: http://www.jetbrains.com/idea/nextversion/free_java_ide.html.”

The Ultimate Edition will continue to be offered commercially as a “complete set of Web and enterprise development tools. … The new features of Version 9 include:

- Java EE 6, with JSF 2.0, JPA 2.0, Servlets 3.0, Bean validation, etc.

- Android, Google App Engine, GWT

- Adobe AIR, FlexUnit

- JavaScript refactorings and debugging

- Tapestry, OSGi

- PHP and more…”

5/30/2009

Java Gets New Garbage Collector, But Only If You Buy Support

Filed under: — Aviran

The monetization of Java has begun. Sun released the Java 1.6.0_14 JDK and JRE today which include a cool new garbage collector called G1. There is just one catch. Even though it is included in the distribution, the release notes state ‘Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased.’ So the Oracle touch is already taking effect. Will OpenJDK be doomed to a feature-castrated backwater while all the good stuff goes into the new Java SE for Business commercial version?

5/21/2009

Mac OS X Users Vulnerable To Major Java Flaw

Filed under: — Aviran

Security researchers say that Mac OS X users are vulnerable to a critical, 6-month-old, remote vulnerability in Java, a component that is enabled by default in Web browsers on this platform.

Julien Tinnes notes that this vulnerability differs from typical Java security flaws in that it is ‘a pure Java vulnerability’ and doesn’t involve any native code. It affected not only Sun’s Java but other implementations such as OpenJDK, on multiple platforms, including Linux and Windows. ‘This means you can write a 100% reliable exploit in pure Java. This exploit will work on all the platforms, all the architectures and all the browsers,’ Julien wrote.

This bug was demonstrated during the Pwn2own security challenge this year at CanSecWest, but the details were not made public at that time. Tinnes recommends that Mac OS X users disable Java in their browsers until Apple releases a security update.

4/30/2009

Java: How To Use HTTP Connect Via Proxy

Filed under: — Aviran Mordo

Java provides a class called java.net.HttpURLConnection which lets you make a single connection to a url, however when you need to make the connection using proxy you are in trouble.

There are couple of methods to connect via proxy. The first one is simply to define system properties which will then let you make an HttpURLConnection using the proxy properties. Here is one way to define the properties

System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("https.proxyPort", "80");

That’s all wonderful with system properties, but what if you need to use a specific proxy for one kind of requests, and another proxy for all others? For instance local HTTP proxy that connects to a corporate proxy and other proxy to connect to the internet, and you need that the requests are issued simultaneously by different threads? Changing system.properties obviously won’t help.

Take a look at abstract class java.net.HttpURLConnection. It requires concrete implementation, and Sun provides one: sun.net.www.protocol.http.HttpURLConnection. It even has a public constructor public HttpURLConnection(URL url, String s, int i), that accepts parameters of target URL, proxy host name and proxy port! All you need to do is instantiate it directly, and not obtain from java.net.URL.openConnection(), and there you go, http connection via proxy.

sun.net.www.protocol.http.HttpURLConnection conn = new HttpURLConnection(requestedURL, "127.0.0.1",80);

2/8/2009

MySQL chief Mickos quits Sun

Filed under: — Aviran Mordo

Former MySQL CEO Marten Mickos is leaving Sun Microsystems, less than a year after Sun paid $1bn for the free-database outfit he helped build.

Sun has confirmed his departure a day after MySQL creator Michael “Monty” Widenius said he was finally leaving the company (to start his own restaurant).

In an email, a Sun spokeswoman said that Mickos would “transition out” of Sun by the end of the company’s fiscal third quarter. That gives him another two months in the job at most.

Mickos is billed as the senior vice president of Sun’s database group, and as he departs, the company will combine the database group with its software infrastructure group. This combined open-source-happy organization - known as the MySQL & software infrastructure group - will be headed by Sun veteran Karen Tegan Padir. Most recently, Padir served as vice president of the company’s enterprise Java platforms group.

1/27/2009

Eclipse Upgrades PHP Development Tools

Filed under: — Aviran Mordo

The Eclipse Foundation announced a major upgrade to the Eclipse PHP Development Tools project, PDT 2.0.

As a leading contributor to the PDT effort, PHP specialist Zend Technologies is pushing PHP as a key element of the Eclipse platform and as a language used for more mainstream development.

“Release 2.0 demonstrates our continued commitment to the Eclipse community,” said Andi Gutmans, co-founder and senior vice president of R&D and alliances at Zend Technologies. “PDT is not only the premier open-source PHP development tool, but is also the basis for Zend’s commercial IDE [integrated development environment] for PHP, Zend Studio for Eclipse. Additionally, in order to further align with Eclipse, PDT will become part of the Eclipse Galileo simultaneous release.”

Eclipse Foundation officials said the focus of the PDT 2.0 release is to add support for the object-oriented programming features of PHP and to improve the overall user experience of the PDT environment. PDT provides all the basic code editing capabilities developers need to get started developing PHP applications.

12/5/2008

Sun Releases JavaFX

Filed under: — Aviran Mordo

Sun released JavaFX 1.0, in a bid to take on Adobe’s Flash and Microsoft’s Silverlight technologies. It is Sun’s first Java release to include standardized, cross-platform audio and video playback code (in the form of On2 licensed codecs). The lack of a Linux or Solaris release is a notable absence. The development kit currently consists of the base run-time, a NetBeans/Eclipse plug-in and a set of artifact exporters for Adobe CS 3&4.”

11/16/2008

Improved jar search tools at jarfinder.com

Filed under: — Aviran Mordo

Jarfinder is an online service for java programmers. We index a massive repository of jars files and provide an online interface to search by class or jar name.

Since our launch in 2006 we’ve helped thousands of programmers resolve ClassNotFoundExceptions and other classpath issues. Following feedback from our users we’ve now made some major updates to the site.

We now track class versions more intelligently. Searches show not only which jars provide classes with the same name but also which jars provide identical versions of each class.

More information is now captured about each jar or class, including the version of the VM that was targeted when compiling.

Ever joined a project with unknown jars on its build path? We’ve added the ability to search for jars by their md5 checksum, so even if jars have been renamed it’s now possible to match them with a precise release.

Via: TheServerSide.com

11/11/2008

Sun to help old foe Microsoft get search traffic

Filed under: — Aviran Mordo

In its latest move to increase Internet search traffic, Microsoft Corp. has turned to an old rival, Sun Microsystems Inc., for marketing help.

Under the terms of a deal being announced Monday, Sun will promote a Microsoft toolbar for the Internet Explorer browser to U.S.-based Web surfers as they download Sun’s Java software - which is required to view some Web sites. The toolbar has a built-in box for queries to Microsoft’s Live Search and buttons that give people access to MSN content.

“We need to provide more volume to our advertisers,” said Angus Norton, a senior director in Microsoft’s Live Search group. Microsoft ranks a distant third in the Web search market behind Google Inc. and Yahoo Inc.

Sun and Microsoft have competed bitterly on several fronts. In particular, Sun was one of the most prominent antagonists in Microsoft’s long antitrust battles. In 2004, Sun reaped nearly $2 billion in a patent and antitrust settlement payout from Microsoft.

Sun and Microsoft did not disclose the financial details or the length of their new deal. It comes as Sun is struggling mightily, having posted a $1.7 billion loss in its most recent quarter.

Powered by WordPress