Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Archives for Avinash Meetoo

Creating a web application using servlets

This topic is part of our Web Application Development in Java training

We will now create a non-trivial Java web application which will require the use of a servlet.

First of all, let’s create a simple HTML page containing a form to allow the user to choose a type of conversion (Rupees to Dollars / Dollars to Rupees) and the amount to convert. At this point, clicking on Go! makes no sense (but try it!)

The second step is to add a servlet to the web application which will handle the conversion. The servlet will be called with two parameters, the type of conversion and the amount, through the HTTP GET (or POST) request. [NB: We will have to add the servlet-api.jar to the web application WEB-INF/lib folder. Get the jar from Tomcat.]

The servlet will then have to get the parameters from the request, validate them and calculate a new amount based on some hard-coded conversion rate (e.g. 1 Dollar is 30 Rupees). This value should then be sent back to the browser (in an HTTP response) for display.

Export the WAR file and examine its contents. Can you see the Java servlet in it? Is it in source code form or in compiled form?

Enhancing the application

As it is, the web application uses a hard-coded conversion rate and this is artificial as, in real life, this rate changes daily. Update the web application to retrieve the conversion rate from a web service.

To make things simple, we are going to assume that the exchange rate is available at an URL similar to www.server.com/exchangerate.txt (see, web services can be simple!) And, because we are dealing with resources which are accessed through a URL, use a Java URL object during the implementation.

Back.

This topic is part of our Web Application Development in Java training

Our forthcoming training courses

  • No training courses are scheduled.

Installing and configuring a servlet

This topic is part of our Web Application Development in Java training

For developing web applications in Java using Servlets and JSP, we will use the following software:

  • OpenJDK: an open source implementation of the Java Platform. OpenJDK is part of most Linux distributions now (as well as on Mac OS X) but needs to be manually installed on Windows.
  • Apache Tomcat: an open source software implementation of the Java Servlet and JavaServer Pages (JSP) technologies. Tomcat is a web container in which web applications written in Java can be deployed for execution.
  • SpringSource Tool Suite: a powerful variant of the open source Eclipse development environment for building Java enterprise applications. STS can be used to create web application in Java and it can also deploy those applications automatically to Tomcat. STS is made by the same people behind the Spring framework.

Installation

As mentioned above, OpenJDK is already installed in Linux. Tomcat and STS need to be installed manually.

Work to do

To check whether the whole environment is setup properly, we will create a small (but fully functional) HelloWorldWeb application using STS and deploy it to Tomcat. On execution, we expect the following:

After testing, export the project as a WAR file and examine the contents of the archive. This WAR file is what is being sent to Tomcat by STS.

This is an overview of how Tomcat works.

Back.

This topic is part of our Web Application Development in Java training

Our forthcoming training courses

  • No training courses are scheduled.

Noupei.com, a social network for people who love Mauritius

Knowledge7 is proud to announce the launching of Noupei.com, the first Mauritian social network for sharing ideas and opinions.

As we are celebrating our 44th anniversary of independence and 20th anniversary as a republic, we believe we need a platform to discuss on the various problems we have in the country as well as the possible solutions.

People can contribute ideas and comment on ideas posted by others. People can also vote for the most valuable contributions.

Noupei.com is open to all people who love Mauritius.

Our forthcoming training courses

  • No training courses are scheduled.

Give your child a head start in his university studies



Congratulations! Your child has just obtained his HSC results and you are proud that he (or she) has worked really well. Having decided to embrace a career in IT, he will start university shortly to study Computer Science.

As you want your child to have a head start in his studies, why not tell your child to learn programming?

At Knowledge7, we offer quality training courses which will give your child the knowledge and skills needed to excel at university level.

We will shortly run an Object-Oriented Programming in Java training starting on 20 March. During this training, your child will master the Java programming language, a platform used by most of the largest companies on the planet and which powers hundred of millions of mobile devices.

After this Java training, we will run an Android Application Development training course as from 8 May. During this training, your child will use his newly acquired knowledge of Java to develop Android applications as used in the latest smartphones and tablets from companies such as Samsung, Sony-Ericsson, LG, HTC, etc.

The training will finish on 5 June 2012, just in time for your child to join university and start his Computer Science classes.

We have trained people from major companies in Mauritius in the past and we are happy that the trainees left us very positive testimonials.

As a sign of encouragement to your child, we are happy to offer him 20% discount if he chooses to follow both the Java and Android training at Knowledge7. We also have free books to offer to those who register early.

Do not hesitate to contact us if you need any clarification.

Our forthcoming training courses

  • No training courses are scheduled.

My presentation on Android during Mobile Apps 2012

What is Android? How to develop apps?

View more presentations from KnowledgeSeven

Thank you for your presence during my presentation this morning at Mobile Apps 2012. I had a lot of pleasure talking about Android and how we can get the best apps for it: either using existing ones from the Android Market, subcontracting the development (to Knowledge7 for example) or by setting up an Android development team (by following our Java and Android training starting soon and getting 20% discount in the process).

I loved the questions & answers session at the end. We had great exchanges about the value of open-source software as well as competing mobile platforms.

Once again, thanks for having listened to me. I hope you learnt 1-2 interesting things.

Our forthcoming training courses

  • No training courses are scheduled.

UNIX/Linux Security Best Practices

You can take steps to protect yourself from intruders who attempt to break into your UNIX or Linux system. Among many of the different security services here are some things to do to make intrusion more difficult.

Turn off unused services

Services which you don’t enable can’t be attacked from the outside. If you don’t provide access to a service, it doesn’t matter if there is any vulnerability in the daemon which would provide that service. So disable anything you don’t need to use.

Where available, install IP filter or firewall rules

Restricting network access helps, it is no security that you won’t be attacked. But restricting access to a smaller group of systems will reduce the number of attempts you see made against you.

Install ssh and tcpd

SSH (Secure SHell) is a protocol which supports logging into a remote system or executing commands on a remote system, using an encrypted communication between the two systems. Both ssh and the tcp wrapper tcpd use a pair of configuration files to define what hosts are allowed to make connections to specific TCP services on your machine. Use these to limit access to those services and prevent unwanted intrusion attempts.

Keep your system up-to-date with the latest patches from your vendor

UNIX and Linux exploits are discovered from time to time, and if you don’t keep your configuration updated, you’ll potentially leave yourself exposed to attacks that try newly discovered vulnerabilities. Get the latest patches for your version of the OS.

UNIX File Sharing

You may want to give others access to your directory or files in one of your directories. As an individual user, you can control who has access to the files which you own, by setting UNIX file permissions. Network File System (NFS) is the most frequently used method of sharing access to a filesystem (or a directory in a filesystem) between UNIX systems.

At this point, if your system does not meet at least the above or if you need to make your Linux production systems compliant with various audit requirements, then our training should offer a good baseline and starting point, see our Linux page for more info in training and consulting services.

Our forthcoming training courses

  • No training courses are scheduled.

Learn Android and get a head start at university



You have your HSC results and you are looking forward to join university for further studies. As you want a career in IT, you have chosen to study Computer Science.

Get a head start and make things simpler later. Learn Java with us, a platform used by most of the largest companies on the planet and which powers millions of mobile devices, including 200 million Android smartphones and tablets. Join our Object-Oriented Programming in Java training course starting on 20 March.

With your new Java skills, you can then follow our Android Application Development training course.

Our forthcoming training courses

  • No training courses are scheduled.

Handling mobile events

This topic is part of our Mobile Application Development with HTML5 training

jQuery Mobile has a number of hooks to handle events such as taps, swipes, etc. In addition to those, the framework also provides more general events such as pageinit and pagebeforeload which allow code to be executed at specific instants in the lifecycle of a page. Finally, there are also a number of methods which can be used to change the behaviour of the web application when specific events occur.

The work to do is:

  • Change the Javascript code already written to be more jQuery Mobile compliant
  • Add a handler for swipeleft on the four songs pages
  • Add a tap handler on the names of the French songs to display a dialog
This topic is part of our Mobile Application Development with HTML5 training

Our forthcoming training courses

  • No training courses are scheduled.

jQuery Mobile for HTML5-based user interfaces

Mobile Application Development with HTML5

Our next Mobile Application Development with HTML5 training starts on 11 February 2015.
This course has been designed for people who wish to develop mobile applications which will run on different platforms. Using latest technologies and features of HTML5 and Javascript, you will build mobile applications which feel and behave mostly like native applications.

Call us on 5834-9001 to book your seat or to get free advice.

There is a lot of debate among mobile developers about whether to go native when building mobile apps or to use HTML5. The latter is particular attractive as the single codebase approach – write once, run everywhere – often implies reduced development costs. Developers can use their existing HTML5/CSS3/JS skills to build applications which can be repackaged easily for different platforms – iOS, Android and others – using tools such as PhoneGap/Cordova. These tools also have a set of plugins which allows developers to use hardware features such as battery, camera and GPS among others.

On the otherhand, a major advantage of native apps is that they are more visually appealing and offer a better user experience when compared to the interface of a cross-platform application build with HTML5.

But is there a way around? I think so.

jQuery Mobile is a framework for developing HTML5-based user interfaces for smartphones and tablets. As it is multi-platform, web applications built with jQuery Mobile, look and feel the same whether one is using Android or IOS devices. The framework also supports Blackberry, Windows Phone, Symbian, etc.

https://www.youtube.com/watch?v=tXRuotrRUfc

This is the framework that trainees are going to use, together with Cordova, during our next Mobile Application Development in HTML5 training. For some time I was wondering whether it would have been better to write all HTML5 code “manually” and, finally, I realised that jQuery Mobile saves a lot of time and has a formidable set of widgets and behaviours which would be difficult to replicate “manually”.

Anyone of you using jQuery Mobile at this moment? What do you think of it?

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #8

You want to receive our Picks of the Week every Monday morning?

Merry Christmas! Thank you for reading the eight edition of Knowledge7’s Picks of the Week on this special day!

Every two weeks, Avinash Meetoo and his team of collaborators will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Recess Framework
Want to build a highly scalable RESTFul archirecture in PHP ? Choose Recess! By Chris Jordan, CEO of New Media Creations. Recess aims at developer joy, whether you are a beginner or a professional, Recess! puts you on the right track to bring life to your server. Running on PHP 5.3, Recess! gives you proper tools to quickly and efficiently build a REST API. Based on the MVC structure, Recess! puts at your fingertips cool developer tools ranging from tools for model,controller and view creating, code introspection and an application route summary that run as a bundled browser app. If ever after using Hibernate in Java, you have been crazy looking a similar one in PHP, then Recess! has a really nice looking ORM that automate a very important aspect, Lazy Loading. Besides being well documented and having a large community, there are many upcomming developments which include plugin system, model validation and an improved templating system for the views. Also, setting it on your server is free from crazy configurations, just download it, place it on your server, set up your database and start creating great apps in Recess!

Google Web Toolkit
GWT, released by Google, is an open source software intented for the creation of Rich Internet Applications. You program in Java and through GWT Compiler, everything is converted to JavaScript. What’s really nice with this software is that while programming in Java, Web Programmers have a wide subset of the Java Libraries with which lots of magic can be done. Moreoever, even if GWT uses Java, its also allows support to wrap JavaScript within Java through JSNI (JavaScript Native Interface). Many other frameworks on the market force a pattern but GWT gives you the freedom to structure your app with any pattern, whether with MVP or MVC or any other. Also, in many cases, Web Programmers have to be browser gurus in the sense they have to understand browsers’ tradeoffs and incompatibilities and implement workarounds. However, with GWT, the compiler handles heterogenous browser platforms by generating several versions of the JavaScript intended for numerous browser engines such as gecko, safari and many others. Well, Web Programmers, what are you waiting for, rush to GWT and start building powerful Rich Internet Applications that gonna surprise web surfers.

HTML Purifier
You want to save HTML from your clients, then bear in mind, not all client are ‘good’, some are really ‘bad’. ‘Bad’ Clients can insert malicious code within the HTML and then perform things that surely you wouldn’t be happy to know. However, to prevent these problems, HTML Purifier is here to parse your HTML from malicious content such as xss. Attackers can place series of xss within HTML. What HTML Purifier really does is that it tokenises the whole HTML content and defeats xss by removing all non-whitelisted elements. Morever, it cleans the HTML through ensuring that HTML contents are well-formed by validating all attributes according to their RFCS. Thus, aftet using HTML Purifier, your document is both safe from malicious code and also W3C compliant. In case , you are using some frameworks, then you are lucky enough because HTML Purifier Plugins are available for some major frameworks such as Drupal, WordPress, Joomla, Symphony and others.

Jahshaka
Formely CineFX, Jahshaka is a video editing software written in QT and uses OpenGL and OpenML. It provides solution for film compositing, editing and special fx system that uses OpenGL and OpenML hardware rendering to give operators real time interactivity. Edit your videos in an easy and flexible way, create effects in real time, animate, paint, add texts, support for many video formats, etc. – these are just a few of key features of this advanced video editor.The program is available for multiple platforms including Linux, Mac OS X and Microsoft Windows. Currently, the official page of Jahshaka shows a countdown to the release of Jahshaka 3.0. But if you are pretty impatient about it like me, you can try out Jashaka 2.0 from here.

JQuery UI
Want to build highly interactive web applications, try JQuery UI. Jquery UI is a widget and interaction library built on top of JQuery JavaScript Library. Jquery UI provides a comprehensive set of core intareaction plugins, UI widgets and visual effects that use a jQuery-style, event-driven architecture and a focus on web standards, accessiblity, flexible styling, and user-friendly design. On top of that, Jquery UI has its own powerful theme framework with a wide theme gallery that also allows you to create your custom theme. With interactions such as Draggable, Droppable and widgets like Accordion and Tabs and amazing Utilities and awsome effects, you can know build great Web Applications that are compliants with major browers such as IE, Firefox, Safari, Opera and Chrome.

The picks for this week have been selected by Noor Bakerally, Research & Development Specialist at Knowledge7.

Our forthcoming training courses

  • No training courses are scheduled.
« Previous Page
Next Page »

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.