Thursday, August 27, 2009

Tree Structure in JSP

Hi,

Its very useful if you want to show some structure in hierarchical way.

Requirement:treetag.jar and taglib49.tld (I can't upload here these files,you can download it form internet)


edit your web.xml file:
description This is the tree structure description
display-name Deepak display-name
servlet-name xmlTree servlet-name
servlet-class xmlTree servlet-class
servlet
servlet-mapping tree servlet-name
url-pattern /run1 url-pattern
servlet-mapping
taglib
taglib-uri /com/cj/tree taglib-uri
taglib-location /WEB-INF/Tag/taglib49.tld taglib-location
taglib
Now write in your jsp following line:
for JSP or in struts application,use following lines:
<%
root=new com.cj.tree.TreeBean();
root.setCode("Root");
root1=new com.cj.tree.TreeBean();
root1.setCode("deepak pandey");

rec("deepak pandey",root1);//this fuction is defined,because i want to get tree dynamically

root.addChild(root1);
%>
<%!
ResultSet rs=null;
com.cj.tree.TreeBean root;
com.cj.tree.TreeBean root1;
void rec(String s1,com.cj.tree.TreeBean root1)
{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/pms1?user=root&password=123");
PreparedStatement ps1=con.prepareStatement("SELECT user_Id,project_name FROM validate v where permittedby=? and Project_Name='PMS'");
ps1.setString(1,s1);
ResultSet rs1=ps1.executeQuery();
while(rs1.next())
{
System.out.println(rs1.getString(1));
com.cj.tree.TreeBean node11=new com.cj.tree.TreeBean();
node11.setCode(""+rs1.getString(1));
rec(rs1.getString(1),node11);
root1.addChild(node11);
}
}
catch(Exception e1){System.out.println("error is"+e1);}
}
%>
tree:createTree defaultConnectors="false" treePicture="order_asc.gif" nodePicture="order_asc.gif" openPicture="order_desc.gif" verticalConnector="vertical.gif" middleConnector="middle.gif" modelBean="<%=root%>" dhtml="true"

Another way :
<%= "This is Tree Structure" %>
tree:createTree dhtml="true"//for image etc write in this tag
tree:addNode code="Deep"
tree:addNode code="Deepak1.1"
tree:addNode code="Deepak1.2"
tree:addNode code="Deepak1.2.1"
tree:addNode code="Deepak1.2.2"
tree:addNode>
tree:addNode code="Deepak1.3"
tree:addNode>
tree:addNode code="Deepak2"
tree:createTree>
tree:createTree>
For any query,you can ask.

Monday, June 29, 2009

a basic application in Struts

Currently i am learning struts and i want to share some basics of it.Here i will tell how to create a basic struts application.

Struts is a free open-source framework for creating Java web applications.

Model-View-Controller (MVC) architecture:
The Model represents the business or database code, the View represents the page design code, and the Controller represents the navigational code. The Struts framework is designed to help developers create web applications that utilize a MVC architecture.(Learn MVC before learning Struts)

The framework provides three key components:

A "request" handler provided by the application developer that is mapped to a standard URI.

A "response" handler that transfers control to another resource which completes the response.

A tag library that helps developers create interactive form-based applications with server pages.

Setting Up Development Environment:

1)jdk 1.6 2)Tomcat 6.0 3)Eclipse

Step 1:-On Eclipse create new Web project and add Struts capabilities.(In myEclipse-->Click on myEclipse and project capabilities and add Struts capabilities)

Step 2:-Now create a New Form,action and JSP.

(select project-->new-->other-->MyEClipse-->WebStruts-->Struts 1.2-->Form,action,jsp)

Give name ,super class(ActionForm)

if you everything is right,it should be there.

Inside src:

1)A form bean:

/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/**
* MyEclipse Struts
* Creation date: 05-20-2009
*
* XDoclet definition:
* @struts.form name="myForm"
*/
public class MyForm extends ActionForm {
/*
* Generated fields
*/


/*
* Generated Methods
*/

/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}

/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
/*here you will get getter and setter of Properties,which you gave*/


}

3)A property file is also there.

# Resources for parameter 'com.yourcompany.struts.ApplicationResources'
# Project StrutsDemo

key=value

2)Action class

/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.MyForm;

/**
* MyEclipse Struts
* Creation date: 03-20-2009
*
* XDoclet definition:
* @struts.action path="/my" name="myForm" input="/form/my.jsp" scope="request" validate="true"
*/
public class MyAction extends Action {
/*
* Generated Methods
*/

/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {

/* Write logic here or function which you want to perform*/
MyForm myForm = (MyForm) form;// TODO Auto-generated method stub


return mapping.findForward null;
}

}

Inside WEB-INF

3)Struts_config

I feel its the heart of struts.

Entries are given below:












attribute="myForm"
input="/form/my.jsp"
name="myForm"
path="/my"
scope="request"
type="com.yourcompany.struts.action.MyAction" >

name="success"
path="/Success.jsp"
redirect="true" />








4)web.xml


action
org.apache.struts.action.ActionServlet

config
/WEB-INF/struts-config.xml


debug
3


detail
3

0


action
*.do


index.jsp

Step 3:Now you can run struts application.Give some fields in your form and try to print them in your JSP,which you will call.

For any mistake,sorry!!

and for query,plz ask.

Thanks

Deepak






Monday, May 4, 2009

Tips for green living

Use Public transport when available.

use a mug or glass for your drinks instead of disposable cups

When traveling on a bike, give lifts to other travelers. Helps save fuel.

Reduce, Re-Use And Re-cycle

Get your vehicles checked and serviced regularly, to reduce carbon and smoke emission

Save water / electricity

Print documents only if neccesary and in fewer number of copies. Use both sides of the page to print (Set this as your default setting). Also you may use advance print options to print multiple pages on the same page.

Car pool to your workplace, it only needs a small adjustment in your schedules. You can socialize and get to know your neighbors and colleagues while driving, reduce your driving stress and save the money spent on fuel and maintenance.

Soak the rice and lentils in water for sometime before you cook, it not only helps you save cooking gas, but is also good for health as the grains absorb water

Once a day, avoid taking lift and climb up to your apartment. It would not only help save the high power consumed by lifts but would also help you reduce those extra calories and the cost of joining the gym.


You should only take and prepare the food as much as you can eat. Do not waste it. If it is going wasted make sure to feed a dog or cow.

Exchange your old appliance for newer one which consumes less energy

Switch Off Your Engine at Traffic Signal

Do not throw used oils of vehicles in drainage which will mix up with water when raining and results in water pollution.

Solar energy is eco-friendly and helps to save electricity

Computer or your PC consumes more electricity than a laptop computer. Encourage employees use laptops in office and save up to 90% of energy.

Pay Online Bills to Save Trees

For further details you can visit following site:
http://www.commonfloor.com/green-living?f=elsjgl

Thursday, April 9, 2009

GeekEvaluation,Online test,Prehiring Test

Last monday,i was chatting with my friend.He asked me some questions about GeekEvaluation.
So i want to again discuss about GeekEvaluation.
GeekEvaluation is web based online assessment and evaluation solution.What features make different from others are following:

1)The most unique feature is that it geekevaluation allows you can add your own questions. You can even import the files and create your own exams.

2)It allows you to customize the exams as per your requirements. You can mix and match various subjects to create your won customized exams.

3)And the important thing that it is not just the technical tests , as the name suggest. You can virtually create any type of tests here.
And the best deal....... while others charge same price if you add your own questions or do not add , geekevaluation charges only $0.99 for each tests.

GeekEvaluation will help you in filtering the candidates,you are looking to hire them in next project.These prehiring tests are designed by experienced programmers & software engineers who know very well what it takes to complete a project successfully.Unlike other sites, we are exclusively focused on evaluating technical expertise of the candidates.

You could find more details of our features here

http://www.geekevaluation.com/features.html



Thanks.
Deepak

Thursday, March 26, 2009

Impact of Nano

Now finally most awaited product of TATA i.e "NANO" CAR hasbeen launched in India.It was normally asked to me that what's the impact of Nano in India.
Last year,It was the hot topic for discussion.Now it hasbeen launched then again it is back.Here i would like to discuss only benifits.
The first benifit is safety.It will provide more safety than a 2 wheeler.The family of four person struggling for space in dangerously wobbling two wheeler.Now Nano will provide a good option.
Second,people have option for buying a small used car to reap the benifits of affordability and fuel efficiency,could choose to buy a new car in form of NANO.Fuel efficiency is also good i.e near about 20km/litre.
Impact of Nano on 2 wheeler segment and used car segment couldbe high relatively high compared to its impact on small car segment,this depends on performance of car,how it stabilises and user reviews of initial performance once it hits the roads.In last,Time will tell how the future of this move pans out. So far the initial response for the product has been mostly positive.

Thanks.

Friday, March 13, 2009

What is market bottom?

AFTER writing off 2008 as a bad dream, the Indian investor is now left wondering whether it is time to call a market bottom anytime soon or if 2009 will be a repeat of the miserable 2008. The year till date has not been particularly encouraging for equity investors with the sensex down about 14% and the mid and small cap indices by a steeper 20% or thereabouts. In addition, the rupee is down another 6% year to date and the foreign institutional investor has continued the selling spree with around $2 billion of net sales in 2009 till date following the $13 billion of sales in 2008. Expert opinion appears divided between a potential market rebound and an imminent crash.
In jan 2008,sensex was above the 20000 but now only 8000.so where is bottom?but
I read it in a newspaper that the intelligent investor should identify companies that can survive the downturn and generate good returns when the tide turns over the next few quarters.
If it is possible then it's a great news for all of us.

Thanks.

Monday, February 23, 2009

Evaluate your technical skill,prehiring test

Hello friends,

Here i want to talk about geekevaluation.(It is web based online assessment and evaluation solution)

Geekevaluation will help you in filtering the candidates,you are looking to hire them in next project
These prehiring tests are designed by experienced programmers & software engineers who know very well what it takes to complete a project successfully.Unlike other sites, we are exclusively focused on evaluating technical expertise of the candidates.

The most unique and exciting feature is that it geekevaluation allows you to add your own questions. You can even import the files and create your own exams.

You can customize the exams as per your requirements. You can mix and match various subjects to create your own customized exams.You can virtually create any type of tests here.

Thanks.

Deepak
Hi friends
JSF (JavaServer Faces) is Sun's standard Java web development technology. This technology greatly simplifies developing web applications and is well suited to create rich web applications. It is a robust component based framework, event driven programming model offering a lot of reusable UI components, extensible architecture, support for multiple client devices etc.You will need the following:JDK1.4,Tomcat 5.0 or any other servlet container (JBoss, Resin, JRun) and Ant.
I hope this information is helpful for you(This information is only for freshers).
For more detail,the links are java.sun.com/javaee/javaserverfaces/ ,en.wikipedia.org/wiki/JavaServer_Faces etc. Thanks. Deepak