Tuesday, 17 August 2010

Different JSON formats

Found the following examples of different JSON formats here.
@XmlRootElement

public static class SimpleJaxbBean 
{

   public String name = "Franz";

   public String surname = "Kafka";

}
XML output:
<simpleJaxbBean>
  <name>Franz</name>
  <surname>Kafka</surname>
</simpleJaxbBean>
Badgerfish format:
{"simpleJaxbBean":{"name":{"$":"Franz"},
"surname":{"$":"Kafka"}}}
Mapped format (Jettison):
{"simpleJaxbBean":{"name":"Franz",
"surname":"Kafka"}}
and finally Jersey default format:
{"name":"Franz",
"surname":"Kafka"}

Monday, 16 August 2010

Installing And Configuring Glassfish on Linux

Installing and configuratin of Glassfish is fairly straightforward if you have some kind of package manager. And who hasn't nowadays?

However, after that the following points come forward:
  • put the logging in /glassfishv3/glassfish/domains/domain1/config/logging.properties in the proper sequence (most detailed first) otherwise, a previous entry may remove the settings of a more specific next entry.

Wednesday, 4 August 2010

When to use redirect en when to use forward

This is just to remind me.

These are the two and the differences:

  • response.sendRedirect("http://www.xyz.com")

    • send a redirect request back to the browser
    • is slow
    • will change the location
  • pageContext.forward("http://www.xyz.com") and requestDispatcher.forward("http://www.xyz.com")

    • sends a forward request right onto the next page/jsp
    • is faster
    • will not change the location
    • you still have access to the original request
  • pageContext.include("http://www.xyz.com") and requestDispatcher.include("http://www.xyz.com")

    • includes a request into the current page/jsp
    • will not change the location
    • you still have access to the original request
    • you can continue processing when you get back control
    • good for including content from another page