Wednesday, November 27, 2013

Expo 2020 Winner : Dubai

Finally the much awaited result of Expo 2020 came out. And the winner is Dubai.


Winner:Dubai. - Connecting minds Creating the future

Finalists
As Dubai, Izmir, Sao Paulo and Ekateringburg competed to host World Expo 2020.

Voting result:
Dubai 


First round result:

Brazil Sao polo: 7.98%
Russia  Ekateringburg  23.93%
Turkey Izmir 20.25%
Dubai 47.24%

Second result:

Russia  Ekateringburg  24.85%
Turkey Izmir 21.82%
Dubai 52.71%

Third Round:

Russia - 
Dubai  -  
Voting process:
  • The final voting process for World Expo 2020 held at the BIE General Assembly in Paris.
  • Each candidate city given the final presentation for 20 minutes.
  • Dubai presented at 10.30 am Paris time (1.30 pm UAE time).
  • Voting for the host country began at 2.00 pm Paris time (5.00 pm UAE time) in a closed room. 
  • There was three rounds of voting before BIE members decide upon a winner.
  • After each round of voting, the candidate city with the least amount of votes will be eliminated. In first round Saopolo eliminated.
  • In second round Izmir eliminated
  • In third round Ekateringburg eliminated
  • Finally BIE announced the name of the Expo 2020 winner Dubai at 5.30 pm Paris time (8.30 pm UAE time).
few Images:

First round results

Second round results
Reference sites:
http://www.expo2020dubai.ae/
http://www.emirates247.com/expo-2020
Share your thoughts

Thursday, November 21, 2013

E-dirham card advantageous

E-Dirham Card

The E-Dirham Card can be used to make payments for a range of things including Emirates ID cards, visa renewals, court cases and even movie tickets.

The first-generation "e-dirhams" were prepaid cards that could only be used to pay for government services at specific ministries.

 "e-Dirham G2"

The G2 prepaid cards are Visa co-branded, which means they can be used to pay for government services as well as many other things.
The cards also come in blue, red and gold options that offer different benefits, and customers do not need to have bank accounts to buy the cards. 

Customers do not need to fill in registration forms for e-dirhams if they only want to deposit up to Dh250 on the cards.They then receive Blue Al Haslah or Red Al Haslah cards. However, customers who want to deposit up to Dh20,000 on their e-dirham cards need to register on the e-Dirham G2 website,

  • Now, owners of the e-Dirham G2 cards can top up the cards using any NBAD deposit machines. 
  • They can also draw cash using any Visa-compatible ATMs around the world.

Problems cardholders had with the first-generation e-dirhams.


  • Customer couldn't top up the card; the card didn't have an expiry date.
  • If we had a transaction that was Dh90 (US$24.50) and you had Dh100 on the card, you'd have Dh10 on the card that you couldn't really withdraw, because there was no way to withdraw the cash," he said.
Share your thoughts

Wednesday, November 20, 2013

Convert date to mysql date format

Following example will help you to convert date in the 01/11/2013 format to mysql accepted date format.

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TesC {
public static void main(String args[]){

String start_dt = "20-11-2013";
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
Date date=null;
try {
date = (Date)formatter.parse(start_dt);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
String finalString = newFormat.format(date);
System.out.println(finalString);
}
}
Output is 2013-11-20
Share your thoughts

Declare BigDecimal value

The following example demonstrates adding of two BigDecimal number.

We are declaring the BigDecimal value first and then adding two BigDecimal values.

package xtrack.web;

import java.math.BigDecimal;

public class TesC {
public static void main(String args[]){
BigDecimal test = new BigDecimal(5);
test=test.add(new BigDecimal(45));
System.out.println(test);
}
}

Prints :50
Share your thoughts

Hibernate native SQL query with GROUP BY Clause

See the example of Hibernate native SQL query with GROUP BY Clause, Also this query contains the logic to retrieve the data in a date range in mysql

Query query = this.sessionFactory.getCurrentSession().createSQLQuery(
"SELECT expenseHead, sum(expense) FROM mb.expense where date<=':date2' and date>= ':date1' group by expenseHead;")
.setParameter("date2", date2)
.setParameter("date1", date1);
List result = query.list();
return result;


Share your thoughts

How to get current date and current month in Java

We can get the current date from the Calendar class as given below.
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
This will print 20/11/2013

And if you want month name from the date follow the below given code
ystem.out.println(new SimpleDateFormat("MMMM").format(cal.getTime()));
Prints November

Full code given below;
public class TesC {
public static void main(String args[]){
String today = (new Date()).toString();
System.out.println(today);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
System.out.println(new SimpleDateFormat("MMMM").format(cal.getTime()));

}
}
output
Wed Nov 20 13:42:33 GST 2013
20/11/2013
November
Share your thoughts

Wednesday, November 13, 2013

Expo 2020 Theme announced.


Expo 2020 : Dubai.
Dubai is the candidate city.

Theme announced.

Share your thoughts

Get a decent accommodation in Dubai


Written on 13/Nov/2013: 

Rental property guide:


Recently I was looking to find a one bedroom house to shift from my studio house in International city. So finding suitable and your dream house is not as easy as we think. I realized that. 

The current situation in Dubai is getting a rocket hike in the rental properties will not be affordable to normal employees like me. Also rumors are spreading that if Dubai will the elected city for Expo 2020 rent will increase further to 20%!.

Currently if you categorized based on cost, the following category will help you to plan
High Costly : JBR, Discovery Gardens, Al khail road, Al Barsha, Tecom, Greens...
Medium Costly: Al Qusais, Al Nahda, Air port Free zone, Deira etc.
Cheap : International city, Motor city, Sports city, Sharjah area which is adjacent to Dubai...

Search house online

The immediate option available is online search for the suitable houses in online websites like dubizzle. These websites contain the advertisement listed by landlords and agents. When you find the suitable house you can have a look by calling the agent or landlord who listed the ad. You have to see the house then only take it. Dont take by seeing only photos.

By calling prominent builders.

We can find the dream house from the builders like al wasl, nakheel, Dubai properties etc. by visiting their website directly. Because these houses are not being listed in the online property search you need to make the call to these proprieties offices and find out the one. If the houses available you can book the house by visiting their premises. Following are the few builders and websites you can contact for the houses.


Get the cheapest house through UAE government.

You can get amazingly cheap houses if you are lucky, There are awqaf building in Al Khail Road and other few places in Dubai. You will get one bed room near about 25,000AED/Yr and 2 Brd room house for 40,000AED/year. Contact details of the awqaf given below. Normally houses won't available and if any vacant who is calling first they will get it. You can try your luck !

AWQAF - http://www.amaf.gov.ae/
fone 04280 8888

Villa Sharing

Expatriates also opting for cheap accommodation like Villa sharing where a group of people take the villa and share among them selves. This will be very economical but as Dubai mandated the rule for Ejari attestation for the propertise for the new visa villa residents is a worrying now to get the new visa.

Share your thoughts

Tuesday, July 30, 2013

Visa for new born baby in Dubai

Congratulation on your new baby, If your baby born in India you can follow the following guidelines to get the visa for your new born baby.

Step 1 : 
Get the birth certificate from Municipality/Panchayath.

Step 2:
Get the affidavit attested by Indian consulate to apply for passport.
Visit the IVS Services Dubai, location near to Oud metha metro station.

Following documents required.

  • Copy of birth certificate
  • Two copies of your passport, first page, last page and visa page
  • Original passport of applicant
  • Two copies of Sworn affidavit filled document, get the document from here link 
  • One passport copy of your spouse
You have to pay of AED 55 in IVS Dubai center and you will get the copy in 1 hour.
Step 3: Get the passport.
Step 4: Get the visa from DNRD.

Related links

  1. IVS website : www.ivsglobalattestation.com

Share your thoughts

Friday, July 5, 2013

Dubai Visa rules : If the resident resides out of the UAE for more than six months.

Resident Permit becomes invalid if the Resident resides out of the UAE for more than Six months.
• Period is calculated as 180 days from the date of departure.

In such cases two options are applicable.

1. Cancel the existing visa and apply for new visa to enter UAE again.
2. Pay Dh100extra for each month after 6 months (180 days), and obtain an Entry Permit from Immigration Department for re-entry. Till completion of seven months re-entry permit fee is Dh230. Then 100 will increase for every month.
• Residence Visa of the person who wants to re-enter must be valid.

For Family: Submit an Arabic letter to Immigration Department requesting re-entry permit. Separate letter should be made for each passport.
Attachments: Passport copy of family member(s) and Sponsor.

For Employee: Submit a letter in Company Letter Head to Immigration Department requesting re-entry permission.

Attachments: Passport copy of Employee, Trade License Copy, Immigration Card Copy & PRO Card Copy. Employee's re-entry permit after six months depends on case to case.
NOTE: The Entry Permit is valid for 15 days from the date of issue. If the Resident couldn't enter within 15 days, new fees to be paid to get another Entry permit.

RE-ENTRY FOR PARENTS: Tenancy Contract, EJARI Registration Certificate and Labour Contract/Salary certificate of the sponsor should be attached with the application to get re-entry permit for the parent(s).

• This service is available at Immigration Head Office at Jaffliya and;
Dubai International Airport (Terminal 3), Gate No.2, Departures area
Phone: 04-707 5388
Timing: Around the clock, seven days a week (including holidays)

• Traveller must hold original Entry permit or it must be submitted at the airport at the time of arrival. If the person wants to enter through other Emirate's airport that has to be mentioned in the application. For any clarification please contact Immigration Call Centre on 800 5111.
Share your thoughts

Saturday, June 8, 2013

Is johnson and johnson's product safe?

Johnson & Johnson, the U.S. healthcare giant, is the well known brand in the baby products for all over the world. They producing all kind of baby products like baby powder, baby shampoo etc.
Is johnson and johnson's product safe?
This question came to the mind of every Indians after the incident that Food and Drug Administration (FDA) recently cancelled Johnson & Johnson India’s licence to produce cosmetic products at their Mulund plant. FDA’s order will come into effect from June 24. According to FDA officials, the order was issued in a case dating back to 2007 when they found that 15 batches of Johnson & Johnson baby powder were sterilized by ethylene oxide, a known carcinogenic and irritant. 
Is johnson and johnson's product safe?

Serious violations : "While ethylene oxide can be used for sterilization  the company did not bother to carry out a test after the process to check the amount of residue in the product," said FDA joint commissioner KB Shende, adding that the company can appeal to the State government before the order comes into effect.

"The products are used for new born babies. It is must for the company to follow all measures," said Shende adding that the traces of ethylene oxide, if any, should have been measured. The 15 batches in question consisted of 1,60,000 containers!!!.

Ethylene Oxide :
very important material used in large-scale chemical production. It also produces ethylene glycol, one of the components used in plastics. Ethylene Oxide has been used globally to produce solvents, lubricants, paint thinners and detergents.

At room temperature, ethylene oxide is very dangerous; the chemical is flammable, carcinogenic, mutagenic, and irritating. It is an anesthetic gas with a misleading pleasant smell.


What Effects Can It Do to Humans?
  • Unprotected and constant exposure to ethylene oxide can cause genetic mutation or DNA alternation which leads to cancer. 
  • It can damage the lungs and the cardiovascular system. 
  • Physical manifestation after exposure includes headache, vomiting, dizziness, sleep disturbances, leg pain, weakness, stiffness, sweating, liver enlargement and suppression of anti-toxic functions of the body
This blog post does not want to tarnish a particular company and its products, instead want to spread awareness to millions of people who using these products for their kid health. 

We want company should prove the product is safe by following all the regulations.
    Share your thoughts

    Friday, May 10, 2013

    How to become a Software Engineer

    How can I become a Software Engineer

    Introduction

    Software engineering (SE) is the application of a systematic, disciplined, quantifiable approach to the design, development, operation, and maintenance of software, and the study of these approaches; that is, the application of engineering to software. People who is mainly handling with software engineering known as Software Engineers.
    Courses and streams

    There are two streams to qualify to become software engineer. Minimum entry criteria is Plus Two. You should study Mathematics as a subject in Plus Two.

    Stream 1

    Join Engineering course in any of the recognized institute. Most preferably you should choose any of the branches below. This courses known B.E. and B.Tech in various universities in India
    How to become a Software Engineer
    How to become a Software Engineer
    • Computer Engineering
    • Information Technology
    • Electronics and Instrumentation
    The branches like Mechanical Engineering, Electrical Engineering etc. also eligible to apply for the various aptitude test conduction by the software companies. But preference will be given to the candidate who studying in computer related subjects like Computer Organization, Software Engineering and various computer languages during engineering.
    You should pass the entrance exam conducting by various authorities to eligible to apply for this courses.

    Stream 2

    If you are not getting selected in the Entrance Exam or didn't get chance to go for engineering study, This stream will help you to become software engineer. 
    You have to study any of the courses given below during graduation
    • Bachelor of Computer Applications
    • Bachelor of Computer Science
    • BSc. Information Technology
    • Any Bachelor degree with Mathematics as a subject.
    Companies like Wipro, Infosys, IBM are conducting the aptitude test after graduation. They will publish the notification in various newspapers and the websites. If you pass the aptitude they will post you as a software engineer trainees and will give the chance to pursue Masters degree in computer science in the affiliated universities.

    You can also go for the post graduation your own for  the following courses after graduation.
    • Master of computer applications MCA
    • MSc Computer Science
    • MSc in Information Technology.
    After passing of Bachelors graduation or any of the above of Masters degree will be eligible to apply in the various IT companies for the post of software engineers.


    Opportunities

    Demand for software engineers increasing year to year as released by Nasscom.The earning potential for software engineers is high compared to other categories for freshers. A fresh software engineer can get a minimum of CTC 2 to 4 lahs in top tier companies.

    Important to note

    You should gain the following to pass the aptitude test and the interviews after that to get a ticket to your dream companies

    For aptitude test

    • Analytical aptitude skill
    • Mathematics skill

    For interview 

    • Good communication skills
    • Knowledge of computer topics like various computer languages, Operating system etc.
    •  Knowledge of computer languages like Java, C, C++ etc.

    Conclusion
    Software engineering is a good career who have thrive to learn and face challenges in the life.
    -------------------------------------------------------------------------------------------------------------------
    Like Facebook page to get further updates on education info-> 



    Share your thoughts

    Thursday, May 9, 2013

    Sample restful web service using Spring framework

    Spring framework helps us to create good restful web service using the Spring's annotation based MVC framework.

    In this example, I am using a) Spring Framework 3.1.1 b) maven 3.0.5 c) Apache Tomcat 6


    Spring Controller class 

    This class will serve as the restful handler class. In this class the methods getStudent(), getAllStudents()have the annotation RequestMapping maps the incoming HTTP request which matches the format /rest/student/{studId} will redirect to the method getStudent(), like that /rest/student/ will redirect to the getAllStudents() method. method = RequestMethod.GET says that the HTTP GET method process by this method. These method returns Student object in the JSON format to the client.

    StudentController.java

    package com.smash.webservices.rest;
    import java.util.List;
    import org.apache.log4j.Logger;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.View;
    import com.smash.domain.Student;
    import com.smash.services.StudentService;
    /**
    * StudentController class will expose a series of Restful end points
    */
    @Controller
    public class StudentController {

    @Autowired
    private StudentService studService;

    @Autowired
    private View jsonView;

    private static final String DATA_FIELD = "data";
    private static final String ERROR_FIELD = "error";

    private static final Logger log = Logger.getLogger(StudentController.class);
    @RequestMapping(value = "/rest/student/", method = RequestMethod.GET)
    public ModelAndView getAllStudents() {
    List studentList = null;

    try {
    studentList = studService.getAllStudents();
    } catch (Exception e) {
    String sMessage = "Error invoking getStudent";
    return getErrorJSON(String.format(sMessage, e.toString()));
    }

    log.debug("Returing Student: " + studentList.toString());
    return new ModelAndView(jsonView, DATA_FIELD, studentList);
    }
    @RequestMapping(value = "/rest/student/{studId}", method = RequestMethod.GET)
    public ModelAndView getStudent(@PathVariable("studId") String studId) {
    Student student = null;

    /* validate student Id parameter */
    if (isEmpty(studId) || studId.length() < 2) {
    String sMessage = "Error invoking getStudent - Invalid student Id parameter";
    return getErrorJSON(sMessage);
    }

    try {
    student = studService.getStudById(studId);
    } catch (Exception e) {
    String sMessage = "Error invoking getStudent. [%1$s]";
    return getErrorJSON(String.format(sMessage, e.toString()));
    }

    log.debug("Returing Student: " + student.toString());
    return new ModelAndView(jsonView, DATA_FIELD, student);
    }

    public static boolean isEmpty(String id) {
    return (null == id) || id.trim().length() == 0;
    }

    /**
    * Create an error REST response.
    * @param sMessage
    * @return
    */
    private ModelAndView getErrorJSON(String sMessage) {
    return new ModelAndView(jsonView, ERROR_FIELD, sMessage);
    }
    /**
    * Injector methods.
    *
    * @param studentService_p
    * the new student service
    */
    public void setStudentService(StudentService studService_p) {
    studService = studService_p;
    }
    }

    Service Class 

    Rest handler class calls the service method to get the data for the view.
    StudentService.java
    package com.smash.services;

    import java.util.ArrayList;
    import java.util.List;
    import org.springframework.stereotype.Service;
    import com.smash.domain.Student;

    @Service
    public class StudentService {

    /**
    * Returns the student details based on ID
    * @param studentId
    * @return
    */
    public Student getStudById(String studentId) {
    Student student = new Student();

    student.setStudentId(studentId);
    student.setName("mark");
    student.setGender('M');
    student.setAddress("Dubai");
    return student;
    }
    /**
    * Returns all student details.From this class you can connect to database through impl-*ementation classes to get the real data
    * @param studentId
    * @return
    */
    public List getAllStudents() {
    Student student = new Student();

    student.setStudentId("101");
    student.setName("Mark");
    student.setGender('M');
    student.setAddress("Dubai");
    List sList= new ArrayList();
    sList.add(student);
    student = new Student();

    student.setStudentId("102");
    student.setName("Steve");
    student.setGender('M');
    student.setAddress("Dubai");
    sList.add(student);
    return sList;
    }
    }

    The Domain Class

    Student.java
    package com.smash.domain;

    public class Student {
    private String studentId;
    private String name;
    private char gender;
    private String address;
    /*get and set methods here*/
    }

    Web.xml file

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID"
    version="2.5">

    <display-name>REST Sample</display-name>

    <!--
    Main configuration file for this Spring web application.
    -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/config/rest-services-config.xml
    </param-value>
    </context-param>

    <!--
    Loads the Spring web application context using the config file defined above.
    -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--
    Define the Spring Dispatcher Servlet for the REST services.
    The 'contextConfiguration' param with an empty value means that the
    Spring Context won't try to load a default file called restservices-servlet.xml
    -->
    <servlet>
    <servlet-name>restservices</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <!--
    This Servlet mapping means that this Servlet will handle all incoming requests
    -->
    <servlet-mapping>
    <servlet-name>restservices</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

    </web-app>

    Restful services configuration file

    rest-services-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.0.xsd">


    <!--
    Enables automatic mapping of fund objects to and from JSON
    -->
    <mvc:annotation-driven/>

    <!--
    Setup spring to pull in @Controller, @RequestMapping, etc Configuration scans specified packages
    for classes configured as Spring managed beans and automatically sets up objects annotated with
    @Controller, @Service etc.
    -->
    <context:component-scan base-package="com.smash.webservices.rest" />
    <context:component-scan base-package="com.smash.services" />

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
    <!--
    Configures view for returning JSON to the client
    -->
    <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
    <property name="contentType" value="text/plain"/>
    </bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
    <util:list id="beanList">
    <ref bean="jsonMessageConverter"/>
    </util:list>
    </property>
    </bean>
    <!--
    Converts JSON to POJO and vice versa
    -->
    <bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>

    </beans>


    Output of the restful web service

    • Get all the student details. URL: 
      http://localhost:8080/rest-sample/rest/student/
    • Get the student based on student Id, GET operation, URL: 
      http://localhost:8080/rest-sample/rest/student/11

    Share your thoughts

    Friday, May 3, 2013

    Form authentication for Restful services

    We can authenticate the restful service using tomcat container specific security mechanism. This can be achieved by configuring the web.xml file. The following example working based on the form based authentication

    web.xml

    <web-app id="WebApp_ID" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee  
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <display-name>Restful Web Application</display-name>
     <servlet>
      <servlet-name>TestServlet</servlet-name>
      <servlet-class>
          com.sun.jersey.spi.container.servlet.ServletContainer
       </servlet-class>
      <init-param>
           <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.smashplus</param-value>
    </init-param>
      <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
      <servlet-name>TestServlet</servlet-name>
      <url-pattern>/resources/*</url-pattern>
     </servlet-mapping>
     <security-constraint>
      <web-resource-collection>
        <web-resource-name>Private</web-resource-name>
        <description>Matches all pages.</description>
        <url-pattern>/resources/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
         <role-name>authenticated-user</role-name>
      </auth-constraint>
    </security-constraint>
    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Public</web-resource-name>
        <description>Matches a few special pages.</description>
      <url-pattern>/index.jsp</url-pattern>
        <url-pattern>/public/*</url-pattern>
      </web-resource-collection>
      <!-- No auth-constraint means everybody has access! -->
    </security-constraint>
    <security-role>
      <description>
        A role for all authenticated ("logged in") users. This
        role must be present in the servlet container's user
        management database.
      </description>
    <role-name>authenticated-user</role-name>
    </security-role>
    <login-config>
      <auth-method>FORM</auth-method>
      <form-login-config>
    <form-login-page>/jsp/LoginForm.html</form-login-page>
    <form-error-page>/jsp/LoginError.html</form-error-page>
    </form-login-config>
    </login-config>
    </web-app>

    You must have the following user configuration in the tomcat-users.xml file.
          <role rolename="authenticated-user" />
    <user username="shams" password="mypass" roles="authenticated-user" />

    How it works*

    The security module configuation works when the url matches */resources/* for eg: http://localhost:8080/restdemo/resources/test/smash this will redirect to the LoginForm.html. This is mappd under the tag <web-resource-name> in the web.xml file aboveLogin page should defined as follows,The action should be j_security_check


    <form method="POST" action="j_security_check">
      Username: <input type="text" name="j_username"><br />
      Password: <input type="password" name="j_password"><br />
      <br />
      <input type="submit" value="Login">
      <input type="reset"  value="Reset">
    </form>

    Screen shot of login form
    In the login form enter the user configured in the tomcat-users.xml file and the authentication works  based on the realm configured in the server.xml file. If the user authentication succeeds redirect to restful service else it will redirect to the error page based on the configuration in the web.xml file.

    The above example uses UserDatabaseRealm which works based on the xml configuration. 

    Related post:


    Share your thoughts

    Monday, April 29, 2013

    create restful web service using eclipse


    In this article I would like to explain the creation of sample restful service,  
    Tools used,

    • Eclipse Indigo
    • Maven build tool
    Create restful web service using jersey.


    We have to install maven plugins in Eclipse to start, follow the below section to install maven tool in Eclipse.

    Install maven tool


    • Also add Maven Integration for Eclipse WTP using the repository 
    http://m2eclipse.sonatype.org/sites/m2e-extras select only ‘Maven Integration for Eclipse WTP’ and install


    In order to set local maven repository go to the workspace and run the command
    mvn -Declipse.workspace= eclipse:add-maven-repo
    if the above command is not working, set the maven_home appropriately in the environment variable.

    Create Project
    Now you have to go and create a new project in the Eclipse. Go New=>project=>Maven Project=> and click next in the final window give as given in the window
    In the final step you can provide as follows
    Now you can remove the junit test classes and packages if you want and you can make the changes in the generated package and class.


    Create a restful web service.

    You can create a restful service class as given below.
    package com.smashplus;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.PathParam;
    import javax.ws.rs.core.Response;
    @Path("/test")
    public class TestRest {
    @GET
    @Path("/{name}")
    public Response getMsg(@PathParam("name") String name) {

    String output = "Hello, " + name;

    return Response.status(200).entity(output).build();
    }
    }
    In the above class we used following annotations. 

    @Path(path) annotation Sets the path to base URL + /path provided. The base URL is based on your application name, the servlet and the URL pattern from the web.xml" configuration file.

    @PathParam : Used to inject parameter values from the URL into a method parameter. This way we can inject values like ID to pass to the restful service.

    @Get : GET Request

    Then we need to add the web.xml file, This will have the mapping to the corresponding restful service class. Here if the request comes matches with the path  /resources/*  it will redirect to the jersey servlet and jersey container will find appropriate resource class available in the mentioned package here it is com.smashplus and the resource class is TestRest. Web.xml file should add in to the path src\main\webapp\WEB-INF\.

    <web-app id="WebApp_ID" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <display-name>Restful Web Application</display-name>

     <servlet>
      <servlet-name>TestServlet</servlet-name>
      <servlet-class>
           com.sun.jersey.spi.container.servlet.ServletContainer
       </servlet-class>
      <init-param>
           <param-name>com.sun.jersey.config.property.packages</param-name>
           <param-value>com.smashplus</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
     </servlet>

     <servlet-mapping>
      <servlet-name>TestServlet</servlet-name>
      <url-pattern>/resources/*</url-pattern>
     </servlet-mapping>

    </web-app>


    final pom.xml file will look like as follows
    ..code excluded..
    <packaging>war</packaging>
    ...code excluded..
    <build>
        <finalName>restdemo</finalName>
        <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>2.3.1</version>
               <configuration>
                   <source>1.6</source>
                   <target>1.6</target>
               </configuration>
           </plugin>
           <plugin>            
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-war-plugin</artifactId>
     <configuration>
       <webXml>src\main\webapp\WEB-INF\web.xml</webXml>        
     </configuration>
    </plugin>
        </plugins>
        </build>
    Now you can deploy the war file to the server. I am using Tomcat 6.0 for the deployment, and visit below service URL http://localhost:8080/restdemo/resources/test/Smashplus

    The output will be,


    Hello, Smashplus
    Download Souce code(select File=>Download) 
    Share your thoughts

    Friday, April 26, 2013

    Disqus Error in Blogger

    If you are getting the below error in IE9 after configuring the Disqus in your blogger site

    This page is forcing your browser to use legacy mode, which is not compatible with Disqus.Please see our troubleshooting guide to get more information about this error.

    Troubleshoot the error

    This error occurring is due to IE7 emulation. Some websites force Internet Explorer to load emulating an older version of Internet Explorer. You can check by opening the development tools (Press F12) and checking the Document Mode.

    If it says Internet Explorer 7 Standards, you can switch this to Internet Explorer 8/9 Standards to load Disqus properly. If you are a user of this webpage you can follow this.



    If you are the owner of this blog you can correct this issue.
    The most common reason the page would load in IE7 standards is because of the EmulateIE7 meta tags. Look in your page source and find an HTML tag similar to this:

    Click on Template->Edit HTML-> Edit Template-> Ctrl+F and Search for 'EmulateIE7' in the editor window. Following line will appear.


    <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>

    You can either remove this or change it to use the latest version of IE available as follows:


    <meta content='IE=9; IE=8; IE=7; IE=EDGE; chrome=1'  http-equiv='X-UA-Compatible'/>


    Then open the development tool again (press F12) in your site and you can see the document mode changed in to IE9 standards. Now the Disqus will load properly.



    Now see the Disqus will appear as follows.

    Try it out..
    Share your thoughts

    Friday, April 19, 2013

    Various Courses after SSLC

    This year SSLC results are publishing after April 25th. Following Lists out the various career path students can can follow after SSLC.

    Higher Secondary Courses .(Plus Two)

    Three different groups are available in Higher Secondary Course. Outlined below. In all the three categories English and any second language is mandatory subject. Second language you can chose based on your likes Mostly students opting for Malayalam, Hindi, Arabic, Urdu. Options for Sanskrit, Syrian French etc are available.

    Following listing out various groups and the options are available.

    a) Science Group
    This group of course will be the first step which moulds based on your interest. If you would like to pursue a career in the Medical Field or Engineering field you have to choose this group.

    Mandatory subjects are Physics and Chemistry,Various sub combinations are available for the rest of the courses as given below.


    •  Mathematics and Biology
    • Mathematics and Computer Science.
    • Home Science and Biology,
    • Mathematics and Home Science.
    • Mathematics and Electronics.
    • Mathematics and Geology.
    • Computer Science and Geology
    • Mathematics, Statistics
    • Biology, Psychology.
    b) Humanities Group

    Combination 1:
    Main: History, Economics, Political Science

    Optional
    • Geography 
    • Sociology
    • Geology
    • Music
    • Gandhian Studies
    • Philosophy
    • Social Work.
    • Psychology
    • Anthropology
    • Malayalam
    Combination 2:

    Main: Islamic History and Culture, Economics, Political Science

    Optional:
    • Geography
    • Sociology
    Combination 3:

    Main: History, Economics, Geography and

    Optional:
    • Malayalam
    • Hindi
    • Arabic
    • Urdu Etc.
    Other combinations are below,
    • History, Philosophy, Sanskrit Sahitya and Sanskrit Sastra.  
    • History, Economics, Political Science and Statistics.
    • Sociology, Social Work, Psychology and Statistics.
    • Economics, Statistics, Anthropology and Social work
    • Economics, Gandhian Studies, Communicative English and Computer applications.
    • Journalism, English Literature, Communicative English and Psychology
    • History, Economics, Sociology and Malayalam
    • History, Economics, Political Science and Malayalam
    • History, Economics, Gandhian Studies and Malayalam
    • Social Work, Journalism, Communicative English and Computer Applications.
    • History, Economics, Sociology and Hindi
    • History, Economics, Sociology and Arabic.
    • Sociology,Journalism,Communicative English and Computer Application
    c) Commerce Group

    Following are the options available in commerce group

    1.Business Studies, Accountancy, Economics, Mathematics.

    2.Business Studies, Accountancy, Economics, Statistics.

    3.Business Studies, Accountancy, Economics, Political Science.

    4.Business Studies, Accountancy, Economics, Computer Applications

    Poly technic Courses

    Following list of courses are offering in the Polytechnic colleges in Kerala.
    1. Civil Engineering
    2. Mechanical Engineering
    3. Electrical & Electronics Engineering
    4. Electronics Engineering
    5. Textile Technology
    6. Computer Engineering
    7. Instrument Technology
    8. Commercial Practice
    9. Electronics & Avionics
    10. Electronics & Instrumentation
    11. Electronics & Communication
    12.Computer Application & Business Management
    13. Computer Hardware and Maintenance

    There are 49 gevernment poly technic colleges are in Kerala also 6 financing colleges spread in 14 districts of Kerala. Above listed courses are offering in these colleges

    List of colleges offering poly technic courses - Visit for details
    Prospectus for the last year 2012-2013 : link you can refer for the details
    Share your thoughts