Tuesday, May 7, 2013

W3C DOM Parser

No comments:
W3C DOM Parser

We can use both jdom as well as w3c dom. In this I am going to explain about w3c dom.


Getting the document on w3c dom.



Some common function for Dom processing


We can specify the xpath value to get the specific tag/ Node.


From other resource example (stackoverflow),

Getting all the tags called "sites" and getting child node value using getTagValue common method.




Happy Coding :)
Read More

Saturday, May 4, 2013

Struts2 Application developemnt with Jquery

No comments:
Struts2 Application developemnt with Jquery

It is very easy to integrate Struts2 applicaiton with Jqery. There are many existing solution that can be used to solve it. No need to start from scratch.

http://struts.jgeppert.com/struts2-jquery-showcase

Which is popular among the jquery plugin. This site is having nice tutorial.

Other Sites :
http://malsup.com/jquery/form/#fields


http://struts.jgeppert.com is also having struts2-bootstap plugin, which contains bootstarp theme that can be integrated with struts2. Instead of struts2 default theme. We can use bootstarp theme.



--
Thank you.


Regards,
Kaleeswaran.S
Read More

Thursday, April 18, 2013

Send JSON data to struts2

No comments:
Send JSON data to struts2


I found a nice article which points out how the struts2 receives json data from UI and returns the json data as response.


We need to add a dependency in pom.xml

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-json-plugin</artifactId>
            <version>${struts2-json-plugin.version}</version>
        </dependency>


In action class just add the interceptor which maps the json data to the actions class.
    <action name="jsonTest" class="com.blah.action.JsonTestAction">          <interceptor-ref name="json">              <param name="contentType">application/json</param>          </interceptor-ref>          <result type="json"/>      </action>

Json data can be returned from strust2 action to View in the form of

        <action name="jsonTest" method="jsonTest" class="com.blah.action.JsonTestAction">
            <result type="json"/>
        </action>


Happy Coding.

--
Thank you.


Regards,
Kaleeswaran.S
Read More

Wednesday, April 17, 2013

Confluence Publisher Plugin with Jenkins

2 comments:
Confluence Publisher Plugin with Jenkins

I integrated confluence publisher plugin with Jenkins. Here are the steps, it may be helpful to some one.

1) First I installed the confluence publisher plugin in jenkins.

2) Created a account in confluence (on demand service).

3) Get the Server Base Url,




Wiki Url will be like,





4) Configure this Confluence Url in jenkins global configuration



5) Then confgiure which file need to be uploaded in Specific job configuration




6) The specified files will be uploaded to the confluence, the jenkins console will be like,




7) Attached files can be found in confluence in the link





Thats it. Enjoy Happy Coding :).

Additional Info :



--
Thank you.


Regards,
Kaleeswaran.S
Read More

Tuesday, April 16, 2013

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure on Mysql, MAMP and MAC OS

No comments:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure on Mysql, MAMP and MAC OS
I just created the a new user in phpmyadmin with all the privileges to all the databases.








and

I used the dependency

    <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.9</version>
    </dependency>

Which didn't work and throwed the exception. After some googling find the solution. I just changed the mysql connector dependency version. Now it is working.

    <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.24</version>
    </dependency>



    public void testTheApp() throws Exception {
        Connection conn = null; 
        try {
//            WARNING: Could not obtain connection metadata
//            java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:
            System.out.println("AppTest started.... ");
            Class.forName("com.mysql.jdbc.Driver");
            Properties connectionProperties = new Properties();
            connectionProperties.put("user", "java");
            connectionProperties.put("password", "java");
            conn = DriverManager.getConnection("jdbc:mysql://0.0.0.0:8889/java", connectionProperties);
            System.out.println("Connection success ...... ");
        } catch (Exception e) {
            e.printStackTrace();
        } finally 
        { 
            if (conn != null) 
            { 
                try 
                { 
                    conn.close (); 
                    System.out.println ("Database connection terminated"); 
                } 
                catch (Exception e) { /* ignore close errors */ } 
            } 
        }
    }

jdbc:mysql://0.0.0.0:8889/java (Works)jdbc:mysql://172.16.23.59:8889/java (Works)
jdbc:mysql://172.0.0.1:8889/java (Wont work)
Happy Coding :)
Read More