Showing posts with label google. Show all posts
Showing posts with label google. Show all posts

2010-05-16

Good Bye JSP

I have tried using JSP on several occasions and every time I realise that I hate it, but when I started playing with Google App Engine(GAE) and the GWT I came to a conclustion that I am not a fan of that either.

I first started with GAE and Python and found that django was quite nice in the way it let you seperate the code and presentation easily, were someone with not python knowladge could easily edit the template.

So I turned to google and types in "JSP alternative", the first one I found was Freemaker so I downloaded the latest version and set out to complete this tutorial. There was one small problem the tutorial was a little out of date and try as I might I could not the the <list>. It turns out the the tutorial is a little old is not for the newest version(2.3.16 at the time of posting) of Freemarker and there have been a few changes with one major change, that being tags such as <list> and <if> now have a # before them so they look like <#list> and <#if> I made the change and the example worked!

To go from JSP to Freemarker I had to make a few changes. First I added freemarker.jar to /war/WEB-INF/lib/.
Next I created a template file called index.html and added to the war folder here is the template.
<html>   <body>   <ul>   <#list files as file>     <li>       <a href="/filestorage?name=${file.name}">${file.name}</a> (${file.mime})     </li>   </#list>   </ul>   <hr />   <form enctype="multipart/form-data" action="/filestorage" method="POST">     <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />     Choose a file to upload:     <input name="uploadedfile" type="file"/>     <br/>     <input type="submit" value="Upload File"/>   </form>   </body> </html>

After that I added a function to the serverlet to set the template values and display the template
/*  * Displays the template  */ private void DisplayTemplate(HttpServletResponse resp) {   //Now loads the data and adds it to a SimpleHash   SimpleHash modelRoot = new SimpleHash();   modelRoot.put("files", FileDAL.getFilesHash());   try {     resp.setContentType("text/html");     Configuration cfg = new Configuration();     Template tpl = cfg.getTemplate("index.html");     tpl.process(modelRoot, resp.getWriter());   } catch (Exception e) {     System.out.println(e.getLocalizedMessage());   } }

Last of all I replaced resp.sendRedirect("/index.jsp"); with DisplayTemplate(resp); and thats it.
The source is available from github.

2009-07-25

The Eclipse IDE and Google App Engine

App Engine is Googles offering in the realm of cloud computing. The free service that Google offers should be more than enough to host small websites. If an application does need extra resources, there is the option to enable flexible billing which alows a web application to scale and only pay for resources used. see Googles Billing Docs Orginally the App Engine only supported the Python scripting language, though the Google team have recently anounced Java support. Google have released an SDK and set of plugins for the Eclipse IDE, together they provide an integrated developement and deployment environment.

How to set up Eclipse/App Engine

Software needed: Installation:
  1. Install the Java SE DEvelopment Kit
  2. Unpack the Eclipse IDE
  3. Follow these steps to install the SDK and App engine plugin through the Eclipse software update service. You will likely need to reboot.
Further Information: App Engine Docs Sample applications

2009-07-16

Subverting Visual Studio

I have recently come across ankhsvn, a free plugin that allows you to use the Subversion version control system. This will be useful for further investigation into the Google .Net api. other useful links -> .Net Gdata online documentation