jr3 (63K)

J2EE 1.4 Content Type Tidbit

Posted by Jessica Wed, 20 Feb 2008 06:25:00 GMT

Using Wireshark, you can detect some subtle differences in the j2ee 1.3 and 1.4 api’s as relating to http responses. One is difference is that PrintWriter appends the charset to the end of the content type (e.g. the MIME type) with a default of iso-8850-1. Also, setting the locale using response.setLocale() after setting the content type also appears to cause the charset to be appended to the content type.

Why is this an interesting find? Well, these extra characters have the potential of breaking things if client side code hasn’t been written well. For instance, a browser plugin that decides what to do with the response based on the MIME type may not know how to deal with a MIME type where ”;charset: iso-8850-1” is appended to the end. If these changes to the api are breaking someone else’s code :-(, you can work around these differences by writing the needed string in a jsp.

See future self, how would you ever have remembered that one if you hadn’t have written it down?

One Useful Infinite Loop

Posted by Jessica Tue, 29 Jan 2008 02:49:00 GMT

If you are ever are in need of a page that would keep a url connection open for an extended period of time, as opposed to simply returned a 404 or 500 error, then you might consider simulating an unresponsive page by creating a page with an infinite loop on it.

<html>
<script>
   function infiniteLoop() {
   var i = 0;

   while (i<=0)
   {
     i = i-1;
   }
}
</script>
<body onload="infiniteLoop()">
</body>
</html>

Ok, so javascript won’t work (that is, you should get a 200 from this page) because it is on the client side, but do the same thing with a jsp or embedded ruby.

<html>
<body>
<% int i = 0;
while (i<=0) {
  i--;
}
%>
</body>
</html>

This is nice for testing timeout parameters on an http connection that you have opened up. For instance, using the java library HttpClient, you can set the connection timeout on a connection. Instead of attempting to connect with the availabe resource, try to connection to this infinite loop page.

Java Web Services

Posted by closetmaster Tue, 24 Jan 2006 23:26:00 GMT

Steps for providing and consuming a web service with Java web services development pack.

Provide
  1. Write and compile .jws file, place in (move to) the correct folder and access with a web browser
  2. Download wsdl file from .jws file in browser, run wsdl2java on it
  3. Find .java files generated by wsdl2java; compile them and move the .class files generated into Tomcat\axis\WEB-INF\classes… folder
Consume
  1. Write html page that POSTs to servlet file; place in servlet folder
  2. Write servlet file that extends HTTPServlet; compile and place in servlet\WEB-INF\classes\package…
  3. Place axis libraries in the lib folder in servlet\WEB-INF

◙ Have J2EE listen on port 8080 and Tomcat listen on 80.

◙ Double check spelling!!!

Is Java Dead?

Posted by closetmaster Fri, 20 Jan 2006 02:55:00 GMT

Well, Java isn’t dead yet. And I venture to guess that it will be quite a while before its in the grave. Even Cobol is still alive… so, Java has got a ways to go. I think the fact that an article was written in 2003 on whether or not java was dead is an indication that it is moving into the later stages of its life cycle. But I


designed by jowensbysandifer