FB og;image not showing original image

Sunday, November 30, 2014

og:image could not be downloaded or is too small  :-

og:image was not defined, could not be downloaded or was not big enough. Please define a chosen image using the og:image metatag, and use an image that's at least 200x200px and is accessible from Facebook. Image 'http://img.example.com/images/imagename.jpg' will be used instead.

Read more...

Integrate FindBugs Plugin With Eclipse

FindBugs Eclipse Plugin :-

This web page provides automatic distribution and updates for the Eclipse plugin for FindBugs.

Plugin requirements

This plugin has primarily been tested with Eclipse 3.3 and 3.4 It should work with 3.x releases, but let us know if you have any problems. The plugin is not compatible with versions of Eclipse preceding 3.3. The plugin runs under Java 1.5/5.0, or newer.

Plugin installation

If you have previously installed a version of the FindBugs plugin prior to mid-May, 2006, then you should remove it first. Simply remove the de.tobject.findbugs_0.0.n directory from Eclipse's pluginsdirectory.
To install the FindBugs plugin:
  1. In Eclipse, click on Help -> Software Update -> Find and Install...
  2. Choose the Search for new features to install option, and click Next.
  3. Click New Remote Site.
  4. Enter the following:
    • Name: FindBugs update site
    • URL: one of the following (note: no final slash on the url)
      • http://findbugs.cs.umd.edu/eclipse for official releases
      • http://findbugs.cs.umd.edu/eclipse-candidate for candidate releases and official releases
      • http://findbugs.cs.umd.edu/eclipse-daily for all releases, including developmental ones
    and click OK.
  5. "FindBugs update site" should appear under Sites to include in search.
    Click the checkbox next to it to select it, and click Finish.
  6. You should see FindBugs Feature under Select features to install.
    (You may have to click on one or two triangles to make it visible in the tree.)
    Select the checkbox next to it and click next.
  7. Select the I accept option to accept the license and click Next.
  8. Make sure the location is correct where you're installing it. The default (your workspace) should be fine. Click Finish.
  9. The plugin is not digitally signed. Go ahead and install it anyway.
  10. Click Yes to make Eclipse restart itself.

Read more...

How to Set Unicode (UTF-8) with Tomcat, Java, MySQL, JDBC, HAProxy?

Monday, November 17, 2014

How to Set Unicode (UTF-8) with Tomcat, Java, MySQL, JDBC, HAProxy ?

Set content-type:charset=UTF-8 :-
One example where we will create a simple page with form to enter Unicode strings and display them. The strings will be saved to MySQL database. We will create UTF-8 database and use JDBC to connect to it from our JSP code.

Step 1:-
            Create a Unicode database and a database user using cPanel or command line:-
            mysql> create database unicode character set utf8 COLLATE utf8_bin;
            mysql> create user unicode@localhost IDENTIFIED BY 'mypass123';
            mysql> grant all on unicode.* to unicode@localhost;
            mysql> flush privileges;
            mysql> use unicode;
            mysql> create table person (name text);
            mysql> \q

           MySQL Connector/J driver connection string has the form of “jdbc:mysql://[hostname]:[port]/[db_name]“


Step 2:-
            now following index.jsp to one of your Tomcat webapps. In our example we put it into ~/apache-tomcat-7.0.5/webapps/ROOT for easy access at root URL of our testing domain. There are a few places in the code where UTF-8 is referenced.

<%@page pageEncoding="UTF-8" language="java" import="java.sql.*"%>
<%@page contentType="text/html;charset=UTF-8"%>

<%
 try{
    request.setCharacterEncoding("UTF-8");
  } catch(Exception e) {}

  out.println("encoding is "+request.getCharacterEncoding());
  out.println("
testing unicode string is 'Miłością'");
  out.println("
request.getLocale() is "+request.getLocale());
  out.println("
response.getLocale() is "+response.getLocale());

  String name = (String)request.getParameter("name");

  java.sql.Connection conn = null;
  try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String jdbc = "jdbc:mysql://localhost/unicode?user=unicode&password=mypass123";
    String jdbcutf8 = "&useUnicode=true&characterEncoding=UTF-8";
    conn = DriverManager.getConnection(jdbc+jdbcutf8);
    String sql = "SELECT name FROM person";
    Statement st = conn.createStatement();

    if(name != null){
// uncomment below line if URIEncoding="UTF-8" is not set in Connector in server.xml
//      name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8");
// comment out below line if URIEncoding="UTF-8" is not set in Connector in server.xml
      name = new String(request.getParameter("name"));
      out.println("
parameter sent is "+name); 
      String sqlInsert = "INSERT INTO person SET name='"+name+"'";
      out.println("
sqlInsert="+sqlInsert);
      st.execute(sqlInsert);
    }

    ResultSet rs = st.executeQuery(sql);
    out.println("

");
    while(rs.next()) { out.print( rs.getObject(1) + "
"); }

  conn.close();
  } catch( Exception ex ) { ex.printStackTrace( new java.io.PrintWriter(out)); }

  %>

 

   
 
   
 

 

You can then access and try the form at your root URL e.g. http://username.jvmhost.net/ or http://username.jvmhost.net:HTTPPORTNUMBER/ if you have an account with JVM Host. By default request parameters and values are ISO-8859-1 encoded so you may need to decode them with

Step 3:-

name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8");

Step 4:- 
Alternatively, you can tell Tomcat to to do the encoding/decoding for you using URIEncoding=”UTF-8″. Below this setting is activated for both HTTP and AJP connectors as both are used by default at JVM Host. You can add URIEncoding in server.xml.


    connectionTimeout="20000" redirectPort="10105" URIEncoding="UTF-8" />

Step 5:-
With this setting active you can just use

name = new String(request.getParameter("name"));
This way you can have any international characters hardcoded in your pages display correctly. Also international characters sent to database via the form are read back and displayed correctly.


Set content-type:charset=UTF-8 in HAProxy:-
pls set below line in backend section just before load balancer servers.
http-response set-header Content-Type text/html;charset=UTF-8


Set Vary:User-Agent in HAProxy:-
pls set below line in backend section just before load balancer servers.
http-response set-header Vary  User-Agent



    

Read more...

RPM remove error: specifies multiple packages

Sunday, November 9, 2014

Mysql Remove Excluding Packages By Removing One My One Packeges:-

You may receive an error message “error: packagename specifies multiple packages” while removing a package with “rpm -e package-name”, for example:

# rpm -e mysql-devel
error: "mysql-devel" specifies multiple packages
This is because the packages of both the architectures (32 and 64 bit) are installed  on the server i.e.
mysql-devel.i386
mysql-devel.x86_64
CentOS, Fedora will list the duplicate packages when you query them using RPM. It won’t list the architecture i.e.
# rpm -qa mysql-devel
mysql-devel
mysql-devel
To list the packages along with their architecture, use the –queryformat option while querying the package,
# rpm -q --queryformat "%{name}.%{arch}\n" mysql-devel
mysql-devel.i386
mysql-devel.x86_64
Now, remove the package you wish to, for example 32 bit package:
# rpm -e mysql-devel.i386

Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP