Wednesday, February 28, 2007
know yourself "Funny Test"
Monday, February 19, 2007
JasperReports
It is a popular open source Java engine which is used for reporting output from many data sources in web and desktop applications .
JasperReports' reports are defined in XML files with an “jrxml” extension which contains of jasperReport , title , pageHeader , detail , pageFooter, band tag element , all of the elements are optional, except for the root jasperReport element.
A jrxml file needs to be compiled , this can be achieved by calling the compileReport() method on the net.sf.jasperreports.engine.JasperCompileManager class .
it needs to be filled with data, this is achieved by calling the fillReport() method on the net.sf.jasperreports.engine.JasperFillManager class which has three parameters an instance of net.sf.jasperreports.engine.JasperReport, a java.util.HashMap containing any parameters passed to the report, and an instance of a java.sql.Connection class .
finally it can be exported to a pdf/Html/xml file , this is achieved by Using :
net.sf.jasperreports.engine.JasperExportManager class and calling exportReportToPdfStream method which create and view the report in output stream 'view in browser' “used with web application” or calling exportReportToPdf method which create the file on the machine without viewing it .
OR
net.sf.jasperreports.view.JasperViewer class and calling viewReport method which create and open the Pdf file .
IReport :
It is used for building Jrxml file better than building it manually .This tool allows users to visually edit complex reports with charts, images, and subreports. iReport is integrated with leading open source chart libraries for java.
Sample code
After creating the jrxml file by Ireport or manually .
// 1- put parameter “examId”
Map parameters = new HashMap();
long examId ;
parameters.put("examId", String.valueOf(examId));
// 2- load and compile report
String jasperJRXMLFileName = “D:/jasperReport.jrxml” ;
JasperDesign jasperDesign = JRXmlLoader.load(jasperJRXMLFileName);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
// 3- DB connection
Connection conn = ResourceManager.getConnection();
// 4- fill report
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,conn);
// 5- create/viewing PDF file .
JasperExportManager.exportReportToPdfStream(jasperPrint,servletResponse.getOutputStream());
servletResponse.getOutputStream().flush();
servletResponse.flushBuffer();
OR
JasperExportManager.exportReportToPdfFile(jasperPrint, "reports/simple_report.pdf");
OR
JasperViewer.viewReport(jasperPrint);
JasperReport Requirements :
http://www.jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/Requirements
you can visit http://jasperforge.org/ , http://jasperreports.sourceforge.net/api/overview-summary.html for more details or download
Thursday, February 15, 2007
Security Chit Chat -2-
The Attack is any action that compromises the security of information owned by an organization ,One may have two classifications of attacks, according to the form of attack and the effect of this attack.
The Forms of Attack :
A- Interruption:-
An asset of the system is destroyed or becomes unavailable. This is an attack on availability. Examples include destruction of a piece of hardware, cutting communication line.
B- Interception:-
An unauthorized party gains access to an asset. This is an attack on confidentiality.
C- Modification:-
An unauthorized party not only gains access but also change the data. This is an attack on Integrity.
D- Fabrication:-
An unauthorized party inserts false object into the system. This is attack on authenticity.
The Effects of Attack :
Another useful categorization according to the effect of these attacks: passive attacks and active attack.
A-Passive Attacks:-
These attacks are in the nature of eavesdropping on, or monitoring of, transmissions. The goal of the opponent is to obtain information that is being transmitted.
B-Active Attacks:-
Attacks which refer to deliberate modifications made to the message stream . also it can be for the purpose of injecting false message or deleting message.
Wednesday, February 7, 2007
Security Chit Chat - 1 -
It is well known that the world now has been involved in a war. Knowledge is the power. Information value enforces owner to protect it from enemies, the enemy who does not sleep, follows modern and effective techniques, and develops his self too to gain the information :-( .
Usually we define the cryptography science as the way of data protection , it handles from being misused, modified, or even seen but It has not been enough . The increasing value of knowledge and the race between cryptography and cryptanalysis has forced to create a way to remove the suspicion of the data existence “Steganography Science”.
Cryptography is the art or science encompassing the principles and methods of transforming an intelligible message into one that is unintelligible and then retransforming that message back to its original form. It can provide protection against eavesdropping, and also protects against message modification and against injection of false message by making it infeasible for an opponent to create cipher text that will be deciphered into accept meaningful plaintext.
Steganography is the art and science of writing hidden messages in such a way that no one apart from the intended recipient knows of the existence of the message; this is in contrast to cryptography, where the existence of the message itself is not disguised, but the content is obscured.
So, for those two important science, how to combine them together in a powerful system to protect your data using fast and easy technology for data communication?
So the Security is very interesting , useful and worthy field ;-).
Tuesday, February 6, 2007
Jsf and Struts
I wanted to put simple summary of different between Jsf and Struts depend only on my little experience .
* Struts :
it is a very popular framework for building web applications , application framework ,representation of the classic Model-View-Controller (MVC) design pattern principles .
Has Actions – Management capabilities, such as Action and DispatchAction which represents all the application requests and dispatches requests to appropriate application components as needed for Controller tier.
Has Form-management capabilities, such as the ActionForm JavaBean that represents the server side state of the input fields on a form, and a validation framework externaliz the configuration of the set of correctness checks to be applied to input field values, plus implement those checks on both the client side and the server side for Model tier.
Has a set of JSP custom tags that can simplify the process of creating the application's HTML markup for the view tier .
Has Tiles framework for layout management, which supports creation of layout templates that can be reused across multiple pages, and thus allows easy modifications to the overall look and feel of an application.
Has Standard configuration "struts-config"file for defining behavior:
- Mapping Action URLs to Action Classes .
- Configuring Action behavior (form bean creation,
validation, return-to-input destination, etc.).
- Mapping Forwards (logical resources) to physical
Pages .
- Defining form beans.
* JSF :
it is a user interface component framework, focuses on the view tier of a Model-View-Controller architecture.
It help to develop the application backend without worrying about HTTP details .
Has Fundamental APIs for user interface components.
Has Event- and listener-model for handling server side events.
Has Value-binding and method-binding-expressions let you bind component properties to objects in your data model and or event handling methods to your business logic, without requiring the components to have any detailed knowledge of the Java classes involved.
Has Converter which is Plug-in for conversion object to string and Validator which is Plug-in for correctness checks on input components
Has Standard configuration "faces-config" file for defining behavior:
- Mapping to Java Bean .
- Configured navigation rules to select the next page(current displayed page , action was invoked, outcome was returned ).
The navigation of Jsf is more clear , easier than struts . JSF provides just the basics for component level validation, while Struts offers a more sophisticated validation mechanism. The important points, though, is that you can code custom validation in JSF if the defaults aren't good enough for your application And all Jsf validation (standard ,Custom or backing beans ) has it’s own phases which stop the Jsf lifecycle competence during failure and also stop your application following . so code and handle all the validation in your business logic if this is not suitable to your application logic .
Which Technology Should I Use?
it may be a good idea to do the Struts-JSF integration library if the application is big and complex. If it's small, it's pretty straight forward to migrate all of it to JSF in one shot J , For a complex user interface the Jsf migration will be better (at least if you're still making user interface changes now and then). For an application with a simple user interface (e.g., mostly simple dynamic output rather than a lot of complex input), or an application that's rarely changed is not important to migrate it to Jsf .