Creational Patterns
Factory Pattern :
Used to create Object Through an interface
Abstract Factory Pattern :
Create an instance of several families of subclasses, It is one more level of abstraction in Factory Pattern
Singleton Pattern :
A class produces only a single instance of its
Builder Pattern :
Prototype Pattern : A pttern to clone an fully initialised object.
Structural Patterns
Adapter Pattern :
A class which connects unrelated classes through interfaces.
Bridge Pattern :
Interface and its implementation of an object is separateed Here.
Composite Pattern :
Used to defined tree structured objects
Decorator Pattern :
Used to add an object at runtime.
Facade Pattern :
A class whic represent entire sub system
Flyweight Pattern :
Proxy Pattern :
Behavioral Patterns (behavioral pattern can alter the program's running behavior.
)
Chain of Responsibility :
Way of passing a request between a chain of objects : Example Excelption handling.
Command Pattern :
command pattern is a design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time
Interpreter Pattern :
Include Language Element in program
Example : "expression ::= plus | minus | variable"
Iterator Pattern :
Used to access collection of object in sequence.
Mediator Pattern :
provides a unified interface to a set of interfaces in a subsystem.
Momento Pattern :
This pattern gets the previous state of an object
Observer Pattern:
A way of notifying change to number of classes
State Pattern :
This pattern is used in computer programming to represent the state of an object. This is a clean way for an object to partially change its type at runtime.
Strategy Pattern :
Encapsulates an algorithm in inside a class.
Template Pattern :
- Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
- Template Method lets subclasses redefine certain steps of an algorithm without letting them to change the algorithm's structure.
Visitor Pattern :
adds a new operation in a class with out changing the class
Saturday, November 28, 2009
Tuesday, November 24, 2009
j2ee design pattern
----------------------------------------------------
>>>>>>>>>>>>>>>>Presentation Tier<<<<<<<<<<<<<<<<<<
---------------------------------------------------
Intercepting Filter :
A centralised control which hadles request from the web client.
--------------------------------------------------------------------------------
Front Controller :
A centralized point of contact for handling a request may be useful, for example, to control and log a user's progress through the site.
What is the difference betwenn Intercepting Filter and Front Controller.
--------------------------------------------------------------------------------
Composite View :
A Framework to present content in a single web page, from numerous data sources.
Tiles is a good example for this pattern
Alos it is good to refer this link
http://java.sun.com/blueprints/patterns/CompositeView.html
1. The client requests service
2. After processing the request, MainServlet (the Front Controller) directs the ScreenFlowManager to select the next view
3. The ScreenFlowManager determines the name of the screen to display
4. The request is forwarded to TemplateServlet
5. The TemplateServlet identifies the requested Screen object and stores it in HttpSession
6. The request is forwarded to the template JSP page
7. The template JSP page executes an insert tag
8. The insert tag retrieves the screen from HttpSession
9. The insert tag inserts the content from the URL corresponding to the value of its parameter attribute
10 - 12. The template JSP page executes another insert tag, which inserts the content as in the steps 7 - 9.
13. Template execution is complete, and the server returns the generated response to the client.
--------------------------------------------------------------------------------
View Helper :
Helpers provide a clean separation between presentation and business data by acting as intermediaries between the two
--------------------------------------------------------------------------------
Dispatcher View :
System controls flow of execution and access to presentation processing, which is responsible for generating dynamic content
--------------------------------------------------------------------------------
Service to Worker :
The system controls flow of execution and access to business data, from which it creates presentation content
Refer Link : http://www.corej2eepatterns.com/Patterns/ServiceToWorker.htm
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Business Tier<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--------------------------------------------------------------------------------
Business Delegate
The business delegate object abstracts the business services API and provides standard interface to al the client components.
--------------------------------------------------------------------------------
Session Facade :
Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
--------------------------------------------------------------------------------
Service Locator
--------------------------------------------------------------------------------
Transfer Object Assembler :
The Transfer Object Assembler uses Transfer Objects to retrieve data from various business objects and other objects that define the model or part of the model.
--------------------------------------------------------------------------------
Value List Handler
--------------------------------------------------------------------------------
Composite Entity
--------------------------------------------------------------------------------
Transfer Object :
A pattern used to "Application clients need to exchange data with enterprise beans".
or
Transfer object / value object is a plain serializable Java class that represents a snapshot of some server side data, as in the following code example:
--------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Integration Tier<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--------------------------------------------------------------------------------
Service Activator :
Enterprise beans and other business services need a way to be activated asynchronously
--------------------------------------------------------------------------------
Data Access Object :
A Pattern which abstracts and encapsulate all access to the database.The DAO manages the connection with the data source to obtain and store data.
Access to persistent storage, such as to a database, varies greatly depending on the type of storage (relational databases, object-oriented databases, flat files, and so forth) and the vendor implementation.
>>>>>>>>>>>>>>>>Presentation Tier<<<<<<<<<<<<<<<<<<
---------------------------------------------------
Intercepting Filter :
A centralised control which hadles request from the web client.
--------------------------------------------------------------------------------
Front Controller :
A centralized point of contact for handling a request may be useful, for example, to control and log a user's progress through the site.
What is the difference betwenn Intercepting Filter and Front Controller.
--------------------------------------------------------------------------------
Composite View :
A Framework to present content in a single web page, from numerous data sources.
Tiles is a good example for this pattern
Alos it is good to refer this link
http://java.sun.com/blueprints/patterns/CompositeView.html
1. The client requests service
2. After processing the request, MainServlet (the Front Controller) directs the ScreenFlowManager to select the next view
3. The ScreenFlowManager determines the name of the screen to display
4. The request is forwarded to TemplateServlet
5. The TemplateServlet identifies the requested Screen object and stores it in HttpSession
6. The request is forwarded to the template JSP page
7. The template JSP page executes an insert tag
8. The insert tag retrieves the screen from HttpSession
9. The insert tag inserts the content from the URL corresponding to the value of its parameter attribute
10 - 12. The template JSP page executes another insert tag, which inserts the content as in the steps 7 - 9.
13. Template execution is complete, and the server returns the generated response to the client.
--------------------------------------------------------------------------------
View Helper :
Helpers provide a clean separation between presentation and business data by acting as intermediaries between the two
--------------------------------------------------------------------------------
Dispatcher View :
System controls flow of execution and access to presentation processing, which is responsible for generating dynamic content
--------------------------------------------------------------------------------
Service to Worker :
The system controls flow of execution and access to business data, from which it creates presentation content
Refer Link : http://www.corej2eepatterns.com/Patterns/ServiceToWorker.htm
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Business Tier<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--------------------------------------------------------------------------------
Business Delegate
The business delegate object abstracts the business services API and provides standard interface to al the client components.
--------------------------------------------------------------------------------
Session Facade :
Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
--------------------------------------------------------------------------------
Service Locator
--------------------------------------------------------------------------------
Transfer Object Assembler :
The Transfer Object Assembler uses Transfer Objects to retrieve data from various business objects and other objects that define the model or part of the model.
--------------------------------------------------------------------------------
Value List Handler
--------------------------------------------------------------------------------
Composite Entity
--------------------------------------------------------------------------------
Transfer Object :
A pattern used to "Application clients need to exchange data with enterprise beans".
or
Transfer object / value object is a plain serializable Java class that represents a snapshot of some server side data, as in the following code example:
--------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Integration Tier<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--------------------------------------------------------------------------------
Service Activator :
Enterprise beans and other business services need a way to be activated asynchronously
--------------------------------------------------------------------------------
Data Access Object :
A Pattern which abstracts and encapsulate all access to the database.The DAO manages the connection with the data source to obtain and store data.
Access to persistent storage, such as to a database, varies greatly depending on the type of storage (relational databases, object-oriented databases, flat files, and so forth) and the vendor implementation.
Friday, November 13, 2009
AJAX with EXCEL POI Import
Import EXCEL Data into Table using POI:
<%@page import="org.apache.poi.poifs.filesystem.POIFSFileSystem"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.apache.poi.hssf.usermodel.*"%>
<html>
<body>
<%
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();
String sql="";
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try{
String url="jdbc:mysql://localhost/csr?user=root&password=";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
//==========
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D:\\ABC.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row;
HSSFCell cell;
int rows; // No of rows
rows = sheet.getPhysicalNumberOfRows();
int cols = 0; // No of columns
int tmp = 0;
out.println("<table border=1>");
// This trick ensures that we get the data properly even if it doesnâ??t start from first few rows
for(int i = 0; i < rows; i++)
{
row = sheet.getRow(i);
if(row != null)
{
tmp = sheet.getRow(i).getPhysicalNumberOfCells();
if(tmp > cols) cols = tmp;
}
else
{
out.println("ROW is null"+ i+"<BR>");
}
}
out.println("Total Row "+rows+"<BR>");
for(int r = 1; r < rows; r++)
{
out.println("Row "+r+"<BR>");
sql = "insert into csr_mst values (";
row = sheet.getRow(r);
if(row != null)
{
// out.println("<tr><td>"+row.getRowNum()+"</td>");
for(int c = 0; c < cols; c++)
{
cell = row.getCell((short)c);
if(cell == null)
{
sql = sql + "'',";
}
else if(cell != null)
{
// Your code here
// s = cell.getData();
// out.println("<td>");
//out.println(cell);
String cellValue = cell.toString();
CharSequence singleQuote = "'";
CharSequence singleQuoteReplace = "`";
if(cellValue.contains("'"))
{
cellValue = cellValue.replace(singleQuote,singleQuoteReplace);
}
sql = sql + "'"+cellValue+"',";
//out.println("</td>");
}
}
// out.println("</tr>");
sql = sql.substring(0,sql.length()-1);
sql = sql +")";
out.println("<BR>"+sql+"<BR>");
//stmt.addBatch(sql);
con.setAutoCommit(false);
stmt.execute(sql);
con.commit();
}
}
con.close();
}
catch (BatchUpdateException be) {
out.println(be.getMessage());
//handle batch update exception
int[] counts = be.getUpdateCounts();
for (int i=0; i< counts.length; i++) {
System.out.println("Statement["+i+"] :"+counts[i]);
}
con.rollback();
}
catch (SQLException e) {
out.println(e.getMessage());
//handle SQL exception
con.rollback();
}
catch(Exception ioe)
{
out.println(ioe.getMessage());
ioe.printStackTrace();
}
out.println("</table>");
out.println("ALL Infomrations are updated successfully");
%>
</body>
</html>
Table structure which is being imported :
CREATE TABLE /*!32312 IF NOT EXISTS*/ "csr_mst" (
"ATS_ID" varchar(200) DEFAULT NULL,
"Application_Name" varchar(200) DEFAULT NULL,
"Application_Acronym" varchar(200) DEFAULT NULL,
"Sector" varchar(200) DEFAULT NULL,
"GSC" varchar(200) DEFAULT NULL,
"CSR_Number" varchar(200) DEFAULT NULL,
"Priority" varchar(200) DEFAULT NULL,
"CSR_Title" varchar(1000) DEFAULT NULL,
"Business_Case" longtext,
"Change_Classification" varchar(200) DEFAULT NULL,
"State" varchar(200) DEFAULT NULL,
"Business_Request_Date" varchar(200) DEFAULT NULL,
"Proposal_Approved_Date" varchar(200) DEFAULT NULL,
"Implemented_Canceled_Date" varchar(200) DEFAULT NULL,
"Request_Submitted_Date" varchar(200) DEFAULT NULL,
"ROM" varchar(200) DEFAULT NULL,
"CRB1_Approved_Date" varchar(200) DEFAULT NULL,
"Final_Estimated_Hours" varchar(200) DEFAULT NULL,
"Proposal_Date" varchar(200) DEFAULT NULL,
"Project_Status" varchar(200) DEFAULT NULL,
"GM_Requestor" varchar(200) DEFAULT NULL,
"GM_Requestor_Phone" varchar(200) DEFAULT NULL,
"GM_Requestor_Email" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead_Phone" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead_Email" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead_Phone" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead_Email" varchar(200) DEFAULT NULL,
"Impl_Mgmt_Number" varchar(200) DEFAULT NULL,
"Proposed_Implementation_Date" varchar(200) DEFAULT NULL,
"CRB2_Approved_Date" varchar(200) DEFAULT NULL,
"Comments" longtext,
"Funding_Source" varchar(200) DEFAULT NULL,
"SOX_Impact" varchar(200) DEFAULT NULL,
"Change_Category" varchar(200) DEFAULT NULL,
"SAP_Code" varchar(200) DEFAULT NULL,
"Attachment00" varchar(200) DEFAULT NULL,
"Note00" longtext,
"Attachment01" varchar(200) DEFAULT NULL,
"Note01" longtext,
"Attachment02" varchar(200) DEFAULT NULL,
"Note02" longtext,
"Attachment03" varchar(200) DEFAULT NULL,
"Note03" longtext,
"Attachment04" varchar(200) DEFAULT NULL,
"Note04" longtext,
"Attachment05" varchar(200) DEFAULT NULL,
"Note05" longtext
) /*!40100 DEFAULT CHARSET=latin1*/;
#
# Dumping data for table 'csr_mst'
#
LOCK TABLES "csr_mst" WRITE;
/*!40000 ALTER TABLE "csr_mst" DISABLE KEYS;*/
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8410.0','14.0','Confiigeration for ZPRC to operated for HNZ','HNZ currently updates the Condition Records Manually into the different condition types and this can lead to errors.','Business Improvement','Design','23-Jun-2009','07-Jul-2008','','02-Jul-2008','Large','07-Jul-2008','105.0','07-Jul-2008','','Jan Smillie','+64 9 9783643','Jan.Smillie@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','07-Jul-2008','"18 Nov - Awaiting resourcing at completion of CR 8923.
07 Nov - This CR is necessary before an important change to DDR payments (CR being drafted by HNZ). Priority increased to 1.4
02 Sep - Placed on hold at GM request, pending refinement of business reqts.
29 Jul - Grant in discussion with Wilhelm/Jan for review of business requirements. Meeting scheduled
07 Jul - ROM submitted"','Discretionary','No','Enhancement','','','0 7/2/2008 It is required that ZPRC program works for HNZ the same way that GMH operates ZPRC, however requires to be altered for HNZ rules.
NZ populates the ZPRC price master tables via an Excel upload file or manual input, including contract table.','','','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8412.0','12.0','BULLETIN INPUT SCREEN (ZDC1) & ZVI001 TABLES - ADD AUSTRALIAN STATE','The business has made a decision via Sales and Marketing to begin processing bonus bulletin payments across each Australian state .','Business Improvement','Testing','01-Oct-2008','04-Jul-2008','','03-Jul-2008','Small','04-Jul-2008','80.0','04-Jul-2008','','LOU BASCHIERA','+61 3 96472534','lou.baschiera@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','04-Jul-2008','"
15 July- UATTesting in progress
8 july - Issues identified during testing in QBS. Team reviewing the code again.
24 June - Build completed. Stamp Duty Claim amount upload successful. Currently testing the automatic claims process
17 june- SOL prepration in progress.
10 june- Priority moved up to 1.2
03 June - SOL prepartion is in progress.
18-May - Team discussing on requirements of bulletin number validation, upload of stamp duty claim file etc. Design and Build could take longer time as the logic to be built is complex
15-May- Clarified points on claim code maintenance and Aus state as unique key field in custom table. additional requirement of bulletin number also was raised
13 May, 4-May- SOL is under progress. Priority changed from 1.9 to 1.5
29Apr - Team discussed with Lou on 21/04/2009. Additional input of claim code needs to be taken care. Also discussed internally on 22/04/2009. Work in progress
24 Apr - Few modifications recognized in SOL. Also, need few clarifications in the process to make this work
22 Apr- ABAP team is modifying SOL to meet the requirements.
17 Mar - Design underway. prasad is working on Design. As other high priority CR`s are in progress, this will be taken care in parallel.
07 Nov - Impacted by LEPA; no development until 25/01/09.
23 Sep - Coding underway.
16 Sep - Design progressing
01 Sep - Seeking customer feedback on requirements.
18 Aug - Working on design in background
07 Aug - Implementation pending completion of VDC project. Will attempt to work around
05 Aug - Design proceeding
22 Jul - Seeking customer feedback on requirements.
04 Jul - ROM submitted and approved."','Discretionary','No','Enhancement','','','0 7/3/2008 Currently Holden has many bonus driveaway deals. These deals are seperated by Australian state due to onroad costs being different across each state.
We would like the facility to add the Australian state to the bulletin input screen (ZDC1','','1 7/3/2008','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8640.0','33.0','CLAIMS NOT PAID ON OPTIONS - (ZDC1)','The business is not able to pay dealers any claims relating to options within the ZDC1 bulletin input screen , causing much frustration and disatisfaction amongst the dealer network across Australia','Business Improvement','Workload','01-Oct-2008','05-Aug-2008','','29-Jul-2008','Large','05-Aug-2008','154.5','04-Aug-2008','','LOU BASCHIERA','+61 3 96472534','lou.baschiera@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','05-Aug-2008','"07 Nov - Impacted by LEPA; no development until 25/01/09.
07 Aug - Placed on hold, pending completion of VDC project.
05 Aug - ROM approved
04 Aug - ROM submitted for approval"','Discretionary','No','Enhancement','','','0 7/29/2008 Currently all Vehicles ("VE") and Smartpacks ("SP" ) are loaded to the bulletin input screen and claims are automatically paid if the retail (RETL) records matches the material codes loaded within the bulletin input screen.
Issue is that a','','','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8748.0','11.0','Create SAP Finance interface to accept SAP Extract file out of LN Sundry Invoicing','Load LN invoice & credit notes into SAP and streamline GMH & HNZ processes.','Business Improvement','Testing','31-Dec-2008','13-Aug-2008','','08-Aug-2008','Small','13-Aug-2008','80.0','12-Aug-2008','','Jan Smillie','+64 9 9783643','Jan.Smillie@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','13-Aug-2008','17 Mar - Customer confirmation that testing will recommence 18/03.
20 Jan - Awaiting UAT.
10 Dec - Testing delayed by CR 9734.
24 Nov - Testing progressing
13 Aug - ROM approved
12 Aug - ROM submitted for approval','Discretionary','No','Enhancement','','','0 8/8/2008 Create a new SAP Finance interface to upload and process a newly generated SAP Extract file out of LN Sundry invoicing.
The SAP Finance interface needs to be able to accept and process a file with the following information:
- Header
- Q','','','','','','','','','','');
<strong>AJAX</strong>
The Ajax technique accomplishes this by using the following technologies:
JavaScript that allows for interaction with the browser and responding to events
The DOM for accessing and manipulating the structure of the HTML of the page
XML, which represents the data passed between the server and client.
An XMLHttpRequest object for asynchronously exchanging the XML data between the client and the server.
The following graphic shows how these technologies work together to update a piece of a page with new data from the server.
Figure 1: General Sequence of Ajax Request
Figure 1 illustrates the following steps in a generalized Ajax request:
The user generates an event, such as by clicking a button. This results in a JavaScript call.
An XMLHttpRequest object is created and configured with a request parameter that includes the ID of the component that generated the event and any value that the user might have entered.
The XMLHttpRequest object makes an asynchronous request to the web server. An object (such as a servlet or listener) receives the request, processes it, and stores any data in the request to the data store. In the case of Ajax-aware JavaServer Faces components, the object that processes the request is a PhaseListener object. We'll cover that more later in the document.
The object that processed the request returns an XML document containing any updates that need to go to the client.
The XMLHttpRequest object receives the XML data, processes it, and updates the HTML DOM representing the page with the new data.
In the below Example
Run ->Call.jsp it invokes db.jsp through Ajax
<strong>
CALL.JSP</strong>
<%@page contentType="text/html"%>
<!-- The above is the page directive with attribute "contentType" which is used to get the content type of the page -->
<%@page pageEncoding="UTF-8"%>
<!-- The above is the page directive with the attribute "pageEncoding" tells us that we are working with unicode encoding within the page -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- We call a ajax.js javascript which makes an asynchronous request to the server -->
<script language="javascript" src="ajax.js"></script> .
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>JSP Page using AJAX
</title>
</head>
<body>
<form name=testFrm">
Sector : <select name="sector" id="sector">
<option value=''></option>
<option value='GME'>GME</option>
<option value='Corp Finance'>Corp Finance</option>
<option value='GMNA'>GMNA</option>
<option value='Corp Staff - EDES'>Corp Staff - EDES</option>
</select>
Application Acronym :
<select name="application_acronym" id="application_acronym">
<option value=''></option>
<option value='eCVMS'>eCVMS</option>
<option value='vcps'>vcps</option>
<option value='e.VPS'>e.VPS</option>
</select>
State : <select name="state" id="state">
<option value=''></option>
<option value='ROM'>ROM</option>
<option value='Design'>Design</option>
<option value='Workload'>Workload</option>
<option value='Testing'>Testing</option>
<option value='Build'>Build</option>
<option value='Deploy'>Deploy</option>
<option value='On Hold'>On Hold</option>
</select>
ATS No : <input type='text' name="ats_id" id="ats_id"/>
CR#: <input type='text' name="csr_number" id="csr_number"/>
<input id="submit" type="button" value="Submit" onclick="sendRequest('GET','db.jsp')">
<div id="ajax_res"> Please get CR detail by entering the above values
</div>
</form>
</body>
</html>
AJAX.js
=======
function createRequestObject(){
var req; try {
// Firefox, Opera, Safari
req = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
//For IE 6
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
//For IE 5
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}
}
}
return req;
}
//Make the XMLHttpRequest Object
var http = createRequestObject();
function sendRequest(method, url){
if(method == 'get' || method == 'GET'){
var ats_id = document.getElementById("ats_id").value;
var sector = document.getElementById("sector").value;
var application_acronym = document.getElementById("application_acronym").value;
var csr_number = document.getElementById("csr_number").value;
var state = document.getElementById("state").value;
url=url+"?ats_id="+ats_id;
url=url+"§or="+sector;
url=url+"&application_acronym="+application_acronym;
url=url+"&csr_number="+csr_number;
url=url+"&state="+state;
url=url+"&sid="+Math.random();
http.open(method,url,true);
http.onreadystatechange = antonyfntest;
http.send(null);}
}
function antonyfntest(){
//alert('Hi Antony');
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response){
document.getElementById("ajax_res").innerHTML = response;
}
}
}
========
DB.JSP
<%@page import="java.sql.*"%>
<html>
<body>
<table>
<tbody>
<div>
<center>
<%
String ats_id= request.getParameter("ats_id");
String sector= request.getParameter("sector");
String application_acronym = request.getParameter("application_acronym");
String csr_number= request.getParameter("csr_number");
String state= request.getParameter("state");
String sql = null;
/*
out.println("<BR>*******************ats_id*********************==>"+ats_id);
out.println("<BR>*******************sector*********************==>"+sector);
out.println("<BR>*******************application_acronym*********************==>"+application_acronym);
out.println("<BR>*******************csr_number*********************==>"+csr_number);
out.println("<BR>*******************state*********************==>"+state);
*/
String condition = null;
if(ats_id != null || sector != null || application_acronym != null || csr_number != null)
{
condition = " where ";
}
if (ats_id != null && !ats_id.equalsIgnoreCase(""))
{
ats_id = ats_id +".0";
condition = condition + "ats_id ='"+ats_id+"' and ";
}
if (sector != null && !sector.equalsIgnoreCase(""))
{
condition = condition + "sector ='"+sector+"' and ";
}
if (application_acronym != null && !application_acronym.equalsIgnoreCase(""))
{
condition = condition + "application_acronym ='"+application_acronym+"' and ";
}
if (csr_number != null && !csr_number.equalsIgnoreCase(""))
{
csr_number = csr_number+".0";
condition = condition + "csr_number ='"+csr_number+"' and ";
}
if (state != null && !state.equalsIgnoreCase(""))
{
condition = condition + "state ='"+state+"' and";
}
//out.println("Copndtin ="+condition);
if(condition!=null)
{
int len = condition.length();
//out.println("Beforecondition"+condition);
condition = condition.substring(1,len-4);
}
else
{
condition = "";
}
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();
Connection con=null;
ResultSet rs=null;
Statement stmt=null;
try{
String url="jdbc:mysql://localhost/csr?user=root&password=";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
sql = "select * from csr_mst " + condition;
rs=stmt.executeQuery(sql);
//out.println("SQL"+sql);
String column="";
ResultSetMetaData rsm =rs.getMetaData();
out.println("<table border=1>");
int cc = rsm.getColumnCount();
System.out.println("running......cnt...."+cc);
int c=1;
String header ="<tr><td>S.No</td>";
for(int i=1;i<=cc;i++)
{
System.out.println("is "+rsm.getColumnName(i));
header = header+"<td>"+rsm.getColumnName(i)+"</td>";
}
header = header+"</tr>";
out.println(header);
int row = 0;
while(rs.next())
{
row= row +1;
System.out.println(row);
out.println("<tr><td>"+row+"</td>");
for(int i=1;i<=cc;i++)
{
//column = column+rs.getString(rsm.getColumnName(i))+"#";
out.println("<td>"+rs.getString(rsm.getColumnName(i))+"</td>");
}
out.println("</tr>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}catch(Exception e){out.println(e.getMessage()+"<BR>"+sql);
}
%>
</tbody>
</table>
</center>
</div>
</body>
</html>
<%@page import="org.apache.poi.poifs.filesystem.POIFSFileSystem"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.apache.poi.hssf.usermodel.*"%>
<html>
<body>
<%
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();
String sql="";
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try{
String url="jdbc:mysql://localhost/csr?user=root&password=";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
//==========
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D:\\ABC.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row;
HSSFCell cell;
int rows; // No of rows
rows = sheet.getPhysicalNumberOfRows();
int cols = 0; // No of columns
int tmp = 0;
out.println("<table border=1>");
// This trick ensures that we get the data properly even if it doesnâ??t start from first few rows
for(int i = 0; i < rows; i++)
{
row = sheet.getRow(i);
if(row != null)
{
tmp = sheet.getRow(i).getPhysicalNumberOfCells();
if(tmp > cols) cols = tmp;
}
else
{
out.println("ROW is null"+ i+"<BR>");
}
}
out.println("Total Row "+rows+"<BR>");
for(int r = 1; r < rows; r++)
{
out.println("Row "+r+"<BR>");
sql = "insert into csr_mst values (";
row = sheet.getRow(r);
if(row != null)
{
// out.println("<tr><td>"+row.getRowNum()+"</td>");
for(int c = 0; c < cols; c++)
{
cell = row.getCell((short)c);
if(cell == null)
{
sql = sql + "'',";
}
else if(cell != null)
{
// Your code here
// s = cell.getData();
// out.println("<td>");
//out.println(cell);
String cellValue = cell.toString();
CharSequence singleQuote = "'";
CharSequence singleQuoteReplace = "`";
if(cellValue.contains("'"))
{
cellValue = cellValue.replace(singleQuote,singleQuoteReplace);
}
sql = sql + "'"+cellValue+"',";
//out.println("</td>");
}
}
// out.println("</tr>");
sql = sql.substring(0,sql.length()-1);
sql = sql +")";
out.println("<BR>"+sql+"<BR>");
//stmt.addBatch(sql);
con.setAutoCommit(false);
stmt.execute(sql);
con.commit();
}
}
con.close();
}
catch (BatchUpdateException be) {
out.println(be.getMessage());
//handle batch update exception
int[] counts = be.getUpdateCounts();
for (int i=0; i< counts.length; i++) {
System.out.println("Statement["+i+"] :"+counts[i]);
}
con.rollback();
}
catch (SQLException e) {
out.println(e.getMessage());
//handle SQL exception
con.rollback();
}
catch(Exception ioe)
{
out.println(ioe.getMessage());
ioe.printStackTrace();
}
out.println("</table>");
out.println("ALL Infomrations are updated successfully");
%>
</body>
</html>
Table structure which is being imported :
CREATE TABLE /*!32312 IF NOT EXISTS*/ "csr_mst" (
"ATS_ID" varchar(200) DEFAULT NULL,
"Application_Name" varchar(200) DEFAULT NULL,
"Application_Acronym" varchar(200) DEFAULT NULL,
"Sector" varchar(200) DEFAULT NULL,
"GSC" varchar(200) DEFAULT NULL,
"CSR_Number" varchar(200) DEFAULT NULL,
"Priority" varchar(200) DEFAULT NULL,
"CSR_Title" varchar(1000) DEFAULT NULL,
"Business_Case" longtext,
"Change_Classification" varchar(200) DEFAULT NULL,
"State" varchar(200) DEFAULT NULL,
"Business_Request_Date" varchar(200) DEFAULT NULL,
"Proposal_Approved_Date" varchar(200) DEFAULT NULL,
"Implemented_Canceled_Date" varchar(200) DEFAULT NULL,
"Request_Submitted_Date" varchar(200) DEFAULT NULL,
"ROM" varchar(200) DEFAULT NULL,
"CRB1_Approved_Date" varchar(200) DEFAULT NULL,
"Final_Estimated_Hours" varchar(200) DEFAULT NULL,
"Proposal_Date" varchar(200) DEFAULT NULL,
"Project_Status" varchar(200) DEFAULT NULL,
"GM_Requestor" varchar(200) DEFAULT NULL,
"GM_Requestor_Phone" varchar(200) DEFAULT NULL,
"GM_Requestor_Email" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead_Phone" varchar(200) DEFAULT NULL,
"GM_Sustain_Lead_Email" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead_Phone" varchar(200) DEFAULT NULL,
"EDS_Sustain_Lead_Email" varchar(200) DEFAULT NULL,
"Impl_Mgmt_Number" varchar(200) DEFAULT NULL,
"Proposed_Implementation_Date" varchar(200) DEFAULT NULL,
"CRB2_Approved_Date" varchar(200) DEFAULT NULL,
"Comments" longtext,
"Funding_Source" varchar(200) DEFAULT NULL,
"SOX_Impact" varchar(200) DEFAULT NULL,
"Change_Category" varchar(200) DEFAULT NULL,
"SAP_Code" varchar(200) DEFAULT NULL,
"Attachment00" varchar(200) DEFAULT NULL,
"Note00" longtext,
"Attachment01" varchar(200) DEFAULT NULL,
"Note01" longtext,
"Attachment02" varchar(200) DEFAULT NULL,
"Note02" longtext,
"Attachment03" varchar(200) DEFAULT NULL,
"Note03" longtext,
"Attachment04" varchar(200) DEFAULT NULL,
"Note04" longtext,
"Attachment05" varchar(200) DEFAULT NULL,
"Note05" longtext
) /*!40100 DEFAULT CHARSET=latin1*/;
#
# Dumping data for table 'csr_mst'
#
LOCK TABLES "csr_mst" WRITE;
/*!40000 ALTER TABLE "csr_mst" DISABLE KEYS;*/
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8410.0','14.0','Confiigeration for ZPRC to operated for HNZ','HNZ currently updates the Condition Records Manually into the different condition types and this can lead to errors.','Business Improvement','Design','23-Jun-2009','07-Jul-2008','','02-Jul-2008','Large','07-Jul-2008','105.0','07-Jul-2008','','Jan Smillie','+64 9 9783643','Jan.Smillie@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','07-Jul-2008','"18 Nov - Awaiting resourcing at completion of CR 8923.
07 Nov - This CR is necessary before an important change to DDR payments (CR being drafted by HNZ). Priority increased to 1.4
02 Sep - Placed on hold at GM request, pending refinement of business reqts.
29 Jul - Grant in discussion with Wilhelm/Jan for review of business requirements. Meeting scheduled
07 Jul - ROM submitted"','Discretionary','No','Enhancement','','','0 7/2/2008 It is required that ZPRC program works for HNZ the same way that GMH operates ZPRC, however requires to be altered for HNZ rules.
NZ populates the ZPRC price master tables via an Excel upload file or manual input, including contract table.','','','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8412.0','12.0','BULLETIN INPUT SCREEN (ZDC1) & ZVI001 TABLES - ADD AUSTRALIAN STATE','The business has made a decision via Sales and Marketing to begin processing bonus bulletin payments across each Australian state .','Business Improvement','Testing','01-Oct-2008','04-Jul-2008','','03-Jul-2008','Small','04-Jul-2008','80.0','04-Jul-2008','','LOU BASCHIERA','+61 3 96472534','lou.baschiera@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','04-Jul-2008','"
15 July- UATTesting in progress
8 july - Issues identified during testing in QBS. Team reviewing the code again.
24 June - Build completed. Stamp Duty Claim amount upload successful. Currently testing the automatic claims process
17 june- SOL prepration in progress.
10 june- Priority moved up to 1.2
03 June - SOL prepartion is in progress.
18-May - Team discussing on requirements of bulletin number validation, upload of stamp duty claim file etc. Design and Build could take longer time as the logic to be built is complex
15-May- Clarified points on claim code maintenance and Aus state as unique key field in custom table. additional requirement of bulletin number also was raised
13 May, 4-May- SOL is under progress. Priority changed from 1.9 to 1.5
29Apr - Team discussed with Lou on 21/04/2009. Additional input of claim code needs to be taken care. Also discussed internally on 22/04/2009. Work in progress
24 Apr - Few modifications recognized in SOL. Also, need few clarifications in the process to make this work
22 Apr- ABAP team is modifying SOL to meet the requirements.
17 Mar - Design underway. prasad is working on Design. As other high priority CR`s are in progress, this will be taken care in parallel.
07 Nov - Impacted by LEPA; no development until 25/01/09.
23 Sep - Coding underway.
16 Sep - Design progressing
01 Sep - Seeking customer feedback on requirements.
18 Aug - Working on design in background
07 Aug - Implementation pending completion of VDC project. Will attempt to work around
05 Aug - Design proceeding
22 Jul - Seeking customer feedback on requirements.
04 Jul - ROM submitted and approved."','Discretionary','No','Enhancement','','','0 7/3/2008 Currently Holden has many bonus driveaway deals. These deals are seperated by Australian state due to onroad costs being different across each state.
We would like the facility to add the Australian state to the bulletin input screen (ZDC1','','1 7/3/2008','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8640.0','33.0','CLAIMS NOT PAID ON OPTIONS - (ZDC1)','The business is not able to pay dealers any claims relating to options within the ZDC1 bulletin input screen , causing much frustration and disatisfaction amongst the dealer network across Australia','Business Improvement','Workload','01-Oct-2008','05-Aug-2008','','29-Jul-2008','Large','05-Aug-2008','154.5','04-Aug-2008','','LOU BASCHIERA','+61 3 96472534','lou.baschiera@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','05-Aug-2008','"07 Nov - Impacted by LEPA; no development until 25/01/09.
07 Aug - Placed on hold, pending completion of VDC project.
05 Aug - ROM approved
04 Aug - ROM submitted for approval"','Discretionary','No','Enhancement','','','0 7/29/2008 Currently all Vehicles ("VE") and Smartpacks ("SP" ) are loaded to the bulletin input screen and claims are automatically paid if the retail (RETL) records matches the material codes loaded within the bulletin input screen.
Issue is that a','','','','','','','','','','');
REPLACE INTO "csr_mst" ("ATS_ID", "Application_Name", "Application_Acronym", "Sector", "GSC", "CSR_Number", "Priority", "CSR_Title", "Business_Case", "Change_Classification", "State", "Business_Request_Date", "Proposal_Approved_Date", "Implemented_Canceled_Date", "Request_Submitted_Date", "ROM", "CRB1_Approved_Date", "Final_Estimated_Hours", "Proposal_Date", "Project_Status", "GM_Requestor", "GM_Requestor_Phone", "GM_Requestor_Email", "GM_Sustain_Lead", "GM_Sustain_Lead_Phone", "GM_Sustain_Lead_Email", "EDS_Sustain_Lead", "EDS_Sustain_Lead_Phone", "EDS_Sustain_Lead_Email", "Impl_Mgmt_Number", "Proposed_Implementation_Date", "CRB2_Approved_Date", "Comments", "Funding_Source", "SOX_Impact", "Change_Category", "SAP_Code", "Attachment00", "Note00", "Attachment01", "Note01", "Attachment02", "Note02", "Attachment03", "Note03", "Attachment04", "Note04", "Attachment05", "Note05") VALUES
('2704.0','SAP Compass','SAP Finance,
PRIDE','GMAP','20','8748.0','11.0','Create SAP Finance interface to accept SAP Extract file out of LN Sundry Invoicing','Load LN invoice & credit notes into SAP and streamline GMH & HNZ processes.','Business Improvement','Testing','31-Dec-2008','13-Aug-2008','','08-Aug-2008','Small','13-Aug-2008','80.0','12-Aug-2008','','Jan Smillie','+64 9 9783643','Jan.Smillie@gm.com','Steven Celar',' +61 3 9038 4666','steven.celar@gm.com','Atul Gokhale','020-66069000','atul.gokhale@eds.com','','','13-Aug-2008','17 Mar - Customer confirmation that testing will recommence 18/03.
20 Jan - Awaiting UAT.
10 Dec - Testing delayed by CR 9734.
24 Nov - Testing progressing
13 Aug - ROM approved
12 Aug - ROM submitted for approval','Discretionary','No','Enhancement','','','0 8/8/2008 Create a new SAP Finance interface to upload and process a newly generated SAP Extract file out of LN Sundry invoicing.
The SAP Finance interface needs to be able to accept and process a file with the following information:
- Header
- Q','','','','','','','','','','');
<strong>AJAX</strong>
The Ajax technique accomplishes this by using the following technologies:
JavaScript that allows for interaction with the browser and responding to events
The DOM for accessing and manipulating the structure of the HTML of the page
XML, which represents the data passed between the server and client.
An XMLHttpRequest object for asynchronously exchanging the XML data between the client and the server.
The following graphic shows how these technologies work together to update a piece of a page with new data from the server.
Figure 1: General Sequence of Ajax Request
Figure 1 illustrates the following steps in a generalized Ajax request:
The user generates an event, such as by clicking a button. This results in a JavaScript call.
An XMLHttpRequest object is created and configured with a request parameter that includes the ID of the component that generated the event and any value that the user might have entered.
The XMLHttpRequest object makes an asynchronous request to the web server. An object (such as a servlet or listener) receives the request, processes it, and stores any data in the request to the data store. In the case of Ajax-aware JavaServer Faces components, the object that processes the request is a PhaseListener object. We'll cover that more later in the document.
The object that processed the request returns an XML document containing any updates that need to go to the client.
The XMLHttpRequest object receives the XML data, processes it, and updates the HTML DOM representing the page with the new data.
In the below Example
Run ->Call.jsp it invokes db.jsp through Ajax
<strong>
CALL.JSP</strong>
<%@page contentType="text/html"%>
<!-- The above is the page directive with attribute "contentType" which is used to get the content type of the page -->
<%@page pageEncoding="UTF-8"%>
<!-- The above is the page directive with the attribute "pageEncoding" tells us that we are working with unicode encoding within the page -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- We call a ajax.js javascript which makes an asynchronous request to the server -->
<script language="javascript" src="ajax.js"></script> .
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>JSP Page using AJAX
</title>
</head>
<body>
<form name=testFrm">
Sector : <select name="sector" id="sector">
<option value=''></option>
<option value='GME'>GME</option>
<option value='Corp Finance'>Corp Finance</option>
<option value='GMNA'>GMNA</option>
<option value='Corp Staff - EDES'>Corp Staff - EDES</option>
</select>
Application Acronym :
<select name="application_acronym" id="application_acronym">
<option value=''></option>
<option value='eCVMS'>eCVMS</option>
<option value='vcps'>vcps</option>
<option value='e.VPS'>e.VPS</option>
</select>
State : <select name="state" id="state">
<option value=''></option>
<option value='ROM'>ROM</option>
<option value='Design'>Design</option>
<option value='Workload'>Workload</option>
<option value='Testing'>Testing</option>
<option value='Build'>Build</option>
<option value='Deploy'>Deploy</option>
<option value='On Hold'>On Hold</option>
</select>
ATS No : <input type='text' name="ats_id" id="ats_id"/>
CR#: <input type='text' name="csr_number" id="csr_number"/>
<input id="submit" type="button" value="Submit" onclick="sendRequest('GET','db.jsp')">
<div id="ajax_res"> Please get CR detail by entering the above values
</div>
</form>
</body>
</html>
AJAX.js
=======
function createRequestObject(){
var req; try {
// Firefox, Opera, Safari
req = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
//For IE 6
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
//For IE 5
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}
}
}
return req;
}
//Make the XMLHttpRequest Object
var http = createRequestObject();
function sendRequest(method, url){
if(method == 'get' || method == 'GET'){
var ats_id = document.getElementById("ats_id").value;
var sector = document.getElementById("sector").value;
var application_acronym = document.getElementById("application_acronym").value;
var csr_number = document.getElementById("csr_number").value;
var state = document.getElementById("state").value;
url=url+"?ats_id="+ats_id;
url=url+"§or="+sector;
url=url+"&application_acronym="+application_acronym;
url=url+"&csr_number="+csr_number;
url=url+"&state="+state;
url=url+"&sid="+Math.random();
http.open(method,url,true);
http.onreadystatechange = antonyfntest;
http.send(null);}
}
function antonyfntest(){
//alert('Hi Antony');
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response){
document.getElementById("ajax_res").innerHTML = response;
}
}
}
========
DB.JSP
<%@page import="java.sql.*"%>
<html>
<body>
<table>
<tbody>
<div>
<center>
<%
String ats_id= request.getParameter("ats_id");
String sector= request.getParameter("sector");
String application_acronym = request.getParameter("application_acronym");
String csr_number= request.getParameter("csr_number");
String state= request.getParameter("state");
String sql = null;
/*
out.println("<BR>*******************ats_id*********************==>"+ats_id);
out.println("<BR>*******************sector*********************==>"+sector);
out.println("<BR>*******************application_acronym*********************==>"+application_acronym);
out.println("<BR>*******************csr_number*********************==>"+csr_number);
out.println("<BR>*******************state*********************==>"+state);
*/
String condition = null;
if(ats_id != null || sector != null || application_acronym != null || csr_number != null)
{
condition = " where ";
}
if (ats_id != null && !ats_id.equalsIgnoreCase(""))
{
ats_id = ats_id +".0";
condition = condition + "ats_id ='"+ats_id+"' and ";
}
if (sector != null && !sector.equalsIgnoreCase(""))
{
condition = condition + "sector ='"+sector+"' and ";
}
if (application_acronym != null && !application_acronym.equalsIgnoreCase(""))
{
condition = condition + "application_acronym ='"+application_acronym+"' and ";
}
if (csr_number != null && !csr_number.equalsIgnoreCase(""))
{
csr_number = csr_number+".0";
condition = condition + "csr_number ='"+csr_number+"' and ";
}
if (state != null && !state.equalsIgnoreCase(""))
{
condition = condition + "state ='"+state+"' and";
}
//out.println("Copndtin ="+condition);
if(condition!=null)
{
int len = condition.length();
//out.println("Beforecondition"+condition);
condition = condition.substring(1,len-4);
}
else
{
condition = "";
}
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();
Connection con=null;
ResultSet rs=null;
Statement stmt=null;
try{
String url="jdbc:mysql://localhost/csr?user=root&password=";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
sql = "select * from csr_mst " + condition;
rs=stmt.executeQuery(sql);
//out.println("SQL"+sql);
String column="";
ResultSetMetaData rsm =rs.getMetaData();
out.println("<table border=1>");
int cc = rsm.getColumnCount();
System.out.println("running......cnt...."+cc);
int c=1;
String header ="<tr><td>S.No</td>";
for(int i=1;i<=cc;i++)
{
System.out.println("is "+rsm.getColumnName(i));
header = header+"<td>"+rsm.getColumnName(i)+"</td>";
}
header = header+"</tr>";
out.println(header);
int row = 0;
while(rs.next())
{
row= row +1;
System.out.println(row);
out.println("<tr><td>"+row+"</td>");
for(int i=1;i<=cc;i++)
{
//column = column+rs.getString(rsm.getColumnName(i))+"#";
out.println("<td>"+rs.getString(rsm.getColumnName(i))+"</td>");
}
out.println("</tr>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}catch(Exception e){out.println(e.getMessage()+"<BR>"+sql);
}
%>
</tbody>
</table>
</center>
</div>
</body>
</html>
Tuesday, November 10, 2009
Saturday, November 7, 2009
Java Interview Question
Questions:
Core
Type I
1. What is Oops?
2. What is function overloading
3. What is function overriding
4.
Type II
1. What is abstract Class?
2. What is Interface?
3. What is a difference between abstract and interface?
4. What is Vector, Array List?2
5. What is Hash table and Hash map
6. What is StringTokenizer?
7. What is the difference between string and string buffer?
8. What is Exception? How many type of Exceptions
9. What is the difference between compile time exception and run time exception
10. What is synchronization
11.
Type III
1. What is Hash Tree and Hash map?
2. What is IO?
3. What is socket and datagram?
4.
Type IV
1. What is Thread?
2. What is wait, Join, sleep?
DataBase:
Standard Questions:
1. How will you connect to the Database?
2. What is mean by Class.forName, sun.jdbc.odbc
3. What is the difference between prepared statement and callable statement.
4. How many types of dirvers available? *
5. What is difference between statement and prepared statement?
6. What is the difference between executeQuery, executeUpdate and execute.
7. What is ResultSet meta data and database meta data? *
8.
9.
Servlet
1. What is servlet?
2. What is the difference between doGet and doPost?
JSP
1. What are the advantages of the JSP
2. What is difference between include and forward? *
3. What is the difference between sendreaderwrite and forward *
4. What are the implicits objects in JSP
5. How will you handle error page in Java. *
6. What is the difference between page, session, request and application
7. How will you make JSP thread at safe? *
8.
Face to Face Interview Questions:
1. How will setup Tomcat:
Core
Type I
1. What is Oops?
2. What is function overloading
3. What is function overriding
4.
Type II
1. What is abstract Class?
2. What is Interface?
3. What is a difference between abstract and interface?
4. What is Vector, Array List?2
5. What is Hash table and Hash map
6. What is StringTokenizer?
7. What is the difference between string and string buffer?
8. What is Exception? How many type of Exceptions
9. What is the difference between compile time exception and run time exception
10. What is synchronization
11.
Type III
1. What is Hash Tree and Hash map?
2. What is IO?
3. What is socket and datagram?
4.
Type IV
1. What is Thread?
2. What is wait, Join, sleep?
DataBase:
Standard Questions:
1. How will you connect to the Database?
2. What is mean by Class.forName, sun.jdbc.odbc
3. What is the difference between prepared statement and callable statement.
4. How many types of dirvers available? *
5. What is difference between statement and prepared statement?
6. What is the difference between executeQuery, executeUpdate and execute.
7. What is ResultSet meta data and database meta data? *
8.
9.
Servlet
1. What is servlet?
2. What is the difference between doGet and doPost?
JSP
1. What are the advantages of the JSP
2. What is difference between include and forward? *
3. What is the difference between sendreaderwrite and forward *
4. What are the implicits objects in JSP
5. How will you handle error page in Java. *
6. What is the difference between page, session, request and application
7. How will you make JSP thread at safe? *
8.
Face to Face Interview Questions:
1. How will setup Tomcat:
HTML ADD Dynamic ROW in table
This code is taken from http://www.mredkj.com/tutorials/tableaddrow.html it is an excellent site for DHTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 40;
el.onkeypress = keyPressTest;
cellRight.appendChild(el);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'selRow' + iteration;
sel.options[0] = new Option('text zero', 'value0');
sel.options[1] = new Option('text one', 'value1');
cellRightSel.appendChild(sel);
}
function keyPressTest(e, obj)
{
var validateChkb = document.getElementById('chkValidateOnKeyPress');
if (validateChkb.checked) {
var displayObj = document.getElementById('spanOutput');
var key;
if(window.event) {
key = window.event.keyCode;
}
else if(e.which) {
key = e.which;
}
var objId;
if (obj != null) {
objId = obj.id;
} else {
objId = this.id;
}
displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
}
}
function removeRowFromTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function openInNewWindow(frm)
{
// open a blank window
var aWindow = window.open('', 'TableAddRowNewWindow',
'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
// set the target to the blank window
frm.target = 'TableAddRowNewWindow';
// submit
frm.submit();
}
function validateRow(frm)
{
var chkb = document.getElementById('chkValidate');
if (chkb.checked) {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length - 1;
var i;
for (i=1; i<=lastRow; i++) {
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0) {
alert('Row ' + i + ' is empty');
return;
}
}
}
openInNewWindow(frm);
}
</script>
</HEAD>
<BODY>
<form action="tableaddrow_nw.html" method="get">
<p>
<input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" />
<input type="button" value="Submit" onclick="validateRow(this.form);" />
<input type="checkbox" id="chkValidate" /> Validate Submit
</p>
<p>
<input type="checkbox" id="chkValidateOnKeyPress" checked="checked" /> Display OnKeyPress
<span id="spanOutput" style="border: 1px solid #000; padding: 3px;"> </span>
</p>
<table border="1" id="tblSample">
<tr>
<th colspan="3">Sample table</th>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="txtRow1"
id="txtRow1" size="40" onkeypress="keyPressTest(event, this);" /></td>
<td>
<select name="selRow0">
<option value="value0">text zero</option>
<option value="value1">text one</option>
</select>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
New Document
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 40;
el.onkeypress = keyPressTest;
cellRight.appendChild(el);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'selRow' + iteration;
sel.options[0] = new Option('text zero', 'value0');
sel.options[1] = new Option('text one', 'value1');
cellRightSel.appendChild(sel);
}
function keyPressTest(e, obj)
{
var validateChkb = document.getElementById('chkValidateOnKeyPress');
if (validateChkb.checked) {
var displayObj = document.getElementById('spanOutput');
var key;
if(window.event) {
key = window.event.keyCode;
}
else if(e.which) {
key = e.which;
}
var objId;
if (obj != null) {
objId = obj.id;
} else {
objId = this.id;
}
displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
}
}
function removeRowFromTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function openInNewWindow(frm)
{
// open a blank window
var aWindow = window.open('', 'TableAddRowNewWindow',
'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
// set the target to the blank window
frm.target = 'TableAddRowNewWindow';
// submit
frm.submit();
}
function validateRow(frm)
{
var chkb = document.getElementById('chkValidate');
if (chkb.checked) {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length - 1;
var i;
for (i=1; i<=lastRow; i++) {
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0) {
alert('Row ' + i + ' is empty');
return;
}
}
}
openInNewWindow(frm);
}
</script>
</HEAD>
<BODY>
<form action="tableaddrow_nw.html" method="get">
<p>
<input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" />
<input type="button" value="Submit" onclick="validateRow(this.form);" />
<input type="checkbox" id="chkValidate" /> Validate Submit
</p>
<p>
<input type="checkbox" id="chkValidateOnKeyPress" checked="checked" /> Display OnKeyPress
<span id="spanOutput" style="border: 1px solid #000; padding: 3px;"> </span>
</p>
<table border="1" id="tblSample">
<tr>
<th colspan="3">Sample table</th>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="txtRow1"
id="txtRow1" size="40" onkeypress="keyPressTest(event, this);" /></td>
<td>
<select name="selRow0">
<option value="value0">text zero</option>
<option value="value1">text one</option>
</select>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
Subscribe to:
Posts (Atom)