Monday 16 March 2015

"invalid key hash" error login with facebook

I created an Android app with Facebook  Log in. I have no problem to run it and log in it, but after log out it when i  log in again it gives me invalid hash key error.

Solution for Invalid Key Hash in android for Facebook:-

click here for generating new hash keyopyYour

1)Copy your SHA-1 key from eclipse ->window->preference->android -> builds->and paste it after open it above link.

2) Separete your SHA-1 key like this "12AB34" or "12 Ab 34" or "12,AB,34" etc input is case-insensetive

3) Then paste it into Hex string and click on convert.

4) Then copy your output (base 64) and () paste it into you Facebook sdk from where you have created hash key &replace it with  output (base 64) key and save it.

Now you will not facing that invalid hash key problem.

Tuesday 6 January 2015

Simple Spring Web Application

              Firstly, create the web dyanamic project in any IDE. and then follow
     the following  steps
    1.  Create Hellocontroller.java class in src folder:
         package com.demo;
         HelloController.java:
         import javax.servlet.http.HttpServletRequest;
         import javax.servlet.http.HttpServletResponse;
         import org.springframework.stereotype.Controller;
         import org.springframework.web.bind.annotation.RequestMapping;
         import org.springframework.web.bind.annotation.RequestMethod;
         import org.springframework.web.servlet.ModelAndView;

         @Controller
          public class HelloController {   
         @RequestMapping(value="first",method=RequestMethod.GET)
          public ModelAndView Hello(){
          ModelAndView mav=new ModelAndView("Hellopage");
          mav.addObject("msg", "Welcom to the Home Page");
          return mav;
             }
          }
   
     2. Modify web.xml:
     
        <?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>Springwebdemo</display-name>
         <servlet>
                <servlet-name>spring-dispatcher</servlet-name>
                <servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>spring-dispatcher</servlet-name>
                <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        </web-app>

      3. Create spring-dispatcher-servlet.xml in WEB-INF:

        <?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:p="http://www.springframework.org/schema/p"
         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/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd">

         <context:component-scan base-package="com.demo"></context:component-scan>
         <bean id="viewResolver"
                          class="org.springframework.web.servlet.view.UrlBasedViewResolver">
                   <property name="viewClass"
                                         value="org.springframework.web.servlet.view.JstlView" />
                   <property name="prefix" value="/WEB-INF/jsp/" />
                   <property name="suffix" value=".jsp" />
        </bean>
        </beans>

     4. Create Hellopage.jsp in WEB-INF:

      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
       pageEncoding="ISO-8859-1"%>
       <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org /TR/html4/loose.dtd">
       <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Basic Info</title>
        </head>
        <body>
        <p> ${msg} </p>

        </body>
        </html>

     5. Create index.jsp in WebContent:

        <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org
        /TR/html4/loose.dtd">
        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Insert title here</title>
        </head>
        <body>
        <a href="first.htm">Basic Info</a>
        </body>
        </html>