Friday, 15 June 2012

J2EE: What is a Struts in our Life ? Struts.

We need to  our life with a easy & smooth track. Now-a-days our technology runs above of the sky with new vision. But , can we feel struts is one of the necessary part of software development , basically on the footprint of JAVA/J2EE.

When I was new to software development ( java/j2ee) at that time struts was new to me & I always afraid about what is that. But, after the span of time slowly slowly deeply I rushed into that struts garden.

Struts framework is an open-source framework for developing the web applications in Java EE, based on MVC-2 architecture. It uses and extends the Java Servlet API. Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java. The term Framework, is way we find to easy developing environment with all possible features for that environment. Its a complete 3rd party(in other way).

Struts components can be categorize into Model, View and Controller:
  • Model: Components like business logic /business processes and data are the part of model.
  • View: HTML, JSP are the view components.
  • Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.
Also Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design.
  • JavaBeans components for managing application state and behavior.
  • Event-driven development (via listeners as in traditional GUI development).
  • Pages that represent MVC-style views; pages reference view roots via the JSF component tree.

But the major role in struts is ActionServlet. ActionServlet is a simple servlet which is the backbone of all Struts applications. It is the main Controller component that handles client requests and determines which Action will process each received request. It serves as an Action factory – creating specific Action classes based on user’s request.It has following roles:
  • Process user requests
  • Determine what the user is trying to achieve according to the request
  • Pull data from the model (if necessary) to be given to the appropriate view,
  • Select the proper view to respond to the user
  • Delegates most of this grunt work to Action classes
  • Is responsible for initialization and clean-up of resources

Except ActionServlet , there is one ActionForm, which may lead you to represent data(Usable component) . ActionForm is javabean which represents the form inputs containing the request parameters from the View referencing the Action bean.It has  2 major methods validate() and reset(). These methods are used by struts framework.

Also ActionMapping, ActionForward,Dispatch Action are play major roles in struts. Follow other reads/posts.

To make your application faster & easy , I follow struts.

Tuesday, 12 June 2012

MySQL : Find all Foreign Keys Constraints in a database (MySql)

I was really Unpleasant when I  failed to find out all foreign keys inside my database. Really, that was a great movement when I did it.My project manager was asking again and again , really I was so happy after the solution.

I can do it in MS SQL Server 2000/2008  , but in mysql its not quite easy.So, I share this in this blog, for help other developers to achive the goal.Below the query you can use it in mysql query editor :-

f.table_schema as 'schema',
f.table_name as 'table' ,
f.column_name as 'column',
f.constraint_name as 'constraint_name'
FROM `information_schema`.`KEY_COLUMN_USAGE` f
f.table_schema='admin_kairali' and f.referenced_column_name  is not null

--Above for a single given table.

f.table_schema as 'schema',
f.table_name as 'table' ,
f.column_name as 'column',
f.constraint_name as 'constraint_name'
FROM `information_schema`.`KEY_COLUMN_USAGE` f
 f.referenced_column_name  is not null

--For all table.

MySQL: Find Number of Engines and their description in Mysql Database System, Like (InnoDB)

I faced this problem to find the information about engines inside Mysql DB. Its quite easy to work with mysql, but the engine inside mysql are so pretty and the information about the engines can be found by using following commands in query editor/console :-

show engine innodb status;

This above  query /command will help you to find the information about a perticular database.Here I used in this query is innodb engine.

show engines;

This above query /command will help you to find following output ( all engines inside your db and some information about those).


1--'MyISAM', 'YES', 'Default engine as of MySQL 3.23 with great performance'
2--'MEMORY', 'YES', 'Hash based, stored in memory, useful for temporary tables'
3--'InnoDB', 'DEFAULT', 'Supports transactions, row-level locking, and foreign keys'
4--'BerkeleyDB', 'NO', 'Supports transactions and page-level locking'
5--'BLACKHOLE', 'YES', '/dev/null storage engine (anything you write to it disappears)'
6--'EXAMPLE', 'NO', 'Example storage engine'
7--'ARCHIVE', 'YES', 'Archive storage engine'
8--'CSV', 'NO', 'CSV storage engine'
9--'ndbcluster', 'NO', 'Clustered, fault-tolerant, memory-based tables'
10--'FEDERATED', 'YES', 'Federated MySQL storage engine'
11--'MRG_MYISAM', 'YES', 'Collection of identical MyISAM tables'
12--'ISAM', 'NO', 'Obsolete storage engine'

Read more about this system internal commands from mysql.

Monday, 11 June 2012

Manoj.Blog: Java Struts: The flavor of DispatchAction. Leave A...

Manoj.Blog: Java Struts: The flavor of DispatchAction. Leave A...: Its really good to know that struts has so many features which provides the programmer/developer easy life.Out of all the good thing the ac...

Java Struts: The flavor of DispatchAction. Leave Action and Love DispatchAction .

Its really good to know that struts has so many features which provides the programmer/developer easy life.Out of all the good thing the action part of struts frame work is superb. As you know there are 5 type of action , provided by struts.

But the Dispatch action make your job function centric. Struts DispatchAction from (org.apache.struts.actions.DispatchAction) is one of the Built-in Actions provided along with the struts framework.It works on a single action with multiple function . No need of create multiple action type for operating any task. It gather all related methods into a single.

An abstract Action that dispatches to a public method that is named by the request parameter whose name is specified by the parameter property of the corresponding ActionMapping. This Action is useful for developers who prefer to combine many similar actions into a single Action class, in order to simplify their application design. Read more on this Dispatch Action.

public class MyDispatch_Action extends DispatchAction


public ActionForward add-data(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) throws Exception{
  System.out.println("You are inside add");
  return mapping.findForward("addmydata");


public ActionForward edit-data(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) throws Exception


  System.out.println("You are inside edit");
    return mapping.findForward("editmydata");


return null;


The rest are same flavor as other struts.Just enjoy new flavor.