Custom Security Via Hashing Password, Use Express For Roles & Handle Browser Cashe.

Servlet configuration To Manage MVC architecture.

<?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:context="http://www.springframework.org/schema/context"
    xmlns:int-security="http://www.springframework.org/schema/integration/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.apache.org/schema/core"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/integration/security http://www.springframework.org/schema/integration/security/spring-integration-security-2.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
   

Default Spring Form Security & Custom Secuity

Follow HttpBasic configuration for web.xml configuration to add Deligating Filter Proxy for spring security and Dispatcher Servlet for manage spring mvc structure.

https://techa2zsolution.blogspot.in/2017/08/http-basic-security-using-spring.html#more

Now creating custom and default spring form like.

Http Basic Security Using Spring Framework


Http Basic Security Using Spring Framework :

In web.xml File

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/dyn-security.xml</param-value>
</context-param>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Send SMS Using Java

private String smsGatewayUserId = "";
    private String smsGatewayPassword = "";
    private String smsGatewayURL = "";
    private String urlEncoding = "UTF-8";
    private String smsGatewaySID = "";

    private static String csvFilePath = "/var/www/";

    public String getMessage(String ar[]) {

        return null;
    }
  
public String sendSMS(String mobileNo, String msg) {

Creating SVN Repository In UBUNTU (Linux) System

1) Up-to-Date Installed Packages
sudo apt-get update
2) Downloading the Subversion, Subversion Tools and Libapache2 packages
you need to run svn subversion and it's tools by using commands
sudo apt-get install subversion subversion-tools libapache2-svn
3) Creating Subversion (SVN) Directory
creating svn directory, where you want to configure svn.
sudo mkdir /home/svn

Maths Server Using Socket Programming

It is time to implement a more comprehensive network application by using the socket programming APIs you have learned so far. A sample math client-server interaction demonstrating online math server that can perform basic math operations,

package com.techa2zsolution.intf.math;

public interface MathService {
    public double add(double firstValue, double secondValue);
    public double sub(double firstValue, double secondValue);
    public double div(double firstValue, double secondValue);
    public double mul(double firstValue, double secondValue);
}

Get the database size, Free space and last update

To get the current database size just by querying into your query browser or CLI from the INFORMATION_SCHEMA database in table TABLES.


SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

Get the database free space

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;

Get the database last update ordered by update time then by create time.

SELECT MAX(UPDATE_TIME), MAX(CREATE_TIME), TABLE_SCHEMA
FROM `TABLES`
GROUP BY TABLE_SCHEMA
ORDER BY 1, 2;

JFree Chart Via Java Programming

PIE Chart Using JFree Chart :
 
First required database connection, as per connection provide sql query to retrieve data from database. 
JDBCPieDataset dataset = new JDBCPieDataset(connection);
        try {
            dataset.executeQuery("SQL QUERY");
                    JFreeChart chart = ChartFactory.createPieChart
                    ("Performance - Report", dataset, true, true, false);
                    chart.setBorderPaint(Color.white);
                    chart.setBorderStroke(new BasicStroke(10.0f));
                    chart.setBorderVisible(true);
                    if (chart != null) {
                        int width = 500;
                        int height = 350;
                        final ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection());
                        response.setContentType("image/png");
                        OutputStream out=response.getOutputStream();
                        ChartUtilities.writeChartAsJPEG(out, chart, width, height,info);
                    }
        }catch (SQLException e) {
            e.printStackTrace();
        }

Line Chart Using Jquery

<!DOCTYPE HTML>
<html>

<head>
<link href="/assets/css/jquery-ui.1.11.2.min.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.canvasjs.min.js"></script>
<script type="text/javascript">

Excel File Data Reading Using Spring MVC

 Uploading EXCEL - 2003, 2007 file's using file uploading UI, and insert all file data into database.

                            <form:form modelAttribute="bulkfileupload" role="form" enctype="multipart/form-data" >
                                            <div class="form-group">
                                                <label>Upload Excel File !</label>
                                                <form:input type="file" path="uploadFile" id="uploadFile"  />
                                                <div class="has-error">
                                                    <form:errors path="uploadFile" class="help-inline" />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <input type="submit" value="upload">
                                            </div>
                                        </form:form>

For handling request of multipart/form-data, required MultipartResolver interface to handle file request. for that configure bean tage in xml file or

Path Variables In Spring Framework

Spring Framework offers to handle URI method parameters by using @PathVariable annotation

@Controller
@RequestMapping("admin")
public class PathVarController {

@RequestMapping("/welcome/{springPathVariable}/{page}")
public ModelAndView pathVariableTest(@PathVariable("page") String name, @PathVariable("springPathVariable") String pathVariable ) {

ModelAndView mav = new ModelAndView("pathVariable");
mav.addObject("message", " "+ name+" Your PathVariable is : "+pathVariable);
return mav;
}
}

Shell Script Tips

Shell Script, delete last 30 day's records from system.

#!/bin/bash
# Delete log files older than 30 days in this script.

find /var/log/tomcat7/localServer/logs/ -mtime +30 -type f -delete
echo "-----------------------------------------------------"
echo "$(date)"
echo "Deleted files older than 30 days in this location :: /var/log/tomcat7/ "