Tuesday, November 30, 2010

Multiple Message Resource Bundle in Struts 1

Target Audience: Web Developer, Web Component Developer

What you should know already: Struts Web Framework, MVC Pattern, Knowledge of struts-config.xml file

Introduction


The message resource class in Struts allows the developer internationalizing web application easy and fast. The user can put labels of fields or description text in a central file and can access them later in the JSP File. The advantage is that you can reuse labels like error messages, titles in multiple JSP files and you can provide the ressource files in multiple languages.

message-resource Element


You might have already seen the message-resource element used in the file struts-config.xml

<message-resources parameter="ApplicationResource" null="false" />


However, it is not often recognized that you can use more than one of these elements in struts-config.xml file. For example, this is a perfectly legal configuration:
<message-resources parameter="ApplicationResrc_English" null="false" />
<message-resources parameter="ApplicationResrc_French" key="fr" />
<message-resources parameter="ApplicationResrc_German" key="gr" />


The first of these - without a key attribute - becomes the default resource set. So, all your JSPs and servlets have access to that set of resources through the servlet context.

Content of ApplicationResrc_English.properties is:
label.register=register
Content of ApplicationResrc_German.properties is:
label.register=registrieren

How to Access?


Your JSP page must indicate a resource if they want to use the non-default set (in this case ApplicationResrc_German). To do this, you will need to use the message tag, part of the bean tag library. So, assume that,

  • you have associated the bean tag library with bean prefix

  • you have got a property in the ApplicationResrc_German bundle with the key label.register, then


<bean:message bundle="gr" key="label.register" />
This will print registrieren

If you use without the bundle attribute, it will pick from the default resource set which from ApplicationResrc_English.properties file.

<bean:message key="label.register" />
This will print register

Thus, by configuring multiple message resource bundles in Struts 1, website can easily be internationalized.

Design Patterns

Some useful definitions of design patterns are:
Desingn patterns constitute a set of rules describing how to accomplish certain tasks in the realm of software development.

Design patterns focus more on reuse of recurring architectural design themes while frameworks focus on detailed design and implementation.

A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it.

Patterns identify and specify abstractions that are above the level of single classes and instances, or of components.

RequisitePro

Target Audience: Analysts, Designers, Project Managers,Team Members, System Integrators

Requirement Management

When you develop software products, failing to manage requirements decreases the probability of meeting the project objectives. Rational RequisitePro helps you manage project requirements.
Requirement Management is the process of eliciting, organizing and documenting requirements of the system. A requirements management process establishes and maintains agreement between the customer and team regarding changing requirements of the system.

What is Rational RequisitePro?

Rational RequisitePro

  • is a requirements management tool

  • enables you to track relationships between requirements

  • provides functionality to analyze the impact of changes to requirements


RequisitePro is integrated with Microsoft Word for creating document-based requirements. Team members use RequisitePro to:

  • plan projects by creating and editing requirements and requirements documents

  • gather, organize and document requirements

  • manage requirements

  • communicate with team members and stakeholders

  • perform project administrative tasks


Benefits of Rational RequisitePro

  • Maintains documents with the requirements dynamically linked to a database which enables sort and query capabilities

  • Identifies the impact of change with traceability features and impact analysis queries

    • scope management and resource allocation decisions



  • Integrates requirements with other life cycle artifacts and processes

    • clear communication accross tools and teams




Rational RequisitePro provides a groundwork for organizing and efficiently managing requirements and project document information


MVC

MVC is a design pattern.

It contains two models. MVC Model 1 and MVC Model 2.

Struts framework implements MVC Design Pattern.
Struts can implement Model 1 and Model 2.

Model 2 most properly describes the application of MVC in a Web-Application context.
Features of MVC1 Architecture:

(1) HTML or JSP files are used to code the presentation. JSP files use java beans to retrieve data if required.
(2)MVC1 architecture is page-centric design all the business and processing logic means any JSP page can either present in the JSP or may be called directly from the JSP page.
(3)Data access is usually done using Custom tag or through java bean call.
Therefore we can say that in MVC1 there is tight coupling between page and model.

Features of MVC2 Architecture:

(1)This architecture removes the page-centric property of MVC1 architecture by separating Presentation, Control logic and Application state
(2)In MVC2 architecture there is one Controller which receive all request for the application and is responsible for taking appropriate action in response to each request.
Second one is Model which is represented by JavaBeans, business object, and database.
Third one is View or is JSP page it takes the information provided by Controller and Module and presents it to user.

Main Difference between MVC1 and MVC2:

The main difference between MVC-I and MVC-II is in MVC-I all the view,control elements are implemented using Servlets. in MVC-II the view is implemented using JSP,and the controller is implemented using Servlets,as JSP provides better user interface than Servlets

OLAP VS OLTP

OLTP Vs OLAP

OLTP(On-Line Transaction Processing)

It is a set of information which processes a data transaction in a database system that manage transaction-oriented applications, typically for data entry and retrieval transaction processing.

OLAP(On-Line Analytical Processing)

OLAP is an approach to quickly provide answers to analytical queries that are multi-dimensional in  nature.It supports the regular retrieving of information depends upon the user input system in real time.

OLTP Vs OLAP

In general we can assume that OLTP systems provide source data to data warehouses, whereas OLAP systems help to analyze it.





















OLTPOLAP
Characterized by a large number of short on-line transactions (INSERT, UPDATE, DELETE).Characterized by relatively low volume of transactions.
OLTP systems is put on very fast query processing, maintaining data integrity.



in multi-access environments.
Queries are often very complex and involve aggregations.
Effectiveness measured by number of transactions per second.For OLAP systemsa response time is an effectiveness measure.

Before OLAP technology was well developed, data had to be extracted from databases using "queries".This meant that the analyst had to structure a request to the database for the information desired, and then
submitted this query to the database server.That server would processing query and return the results.

Depending on the size of the database and the data requested, this query could take minutes or hours to complete.In this sense, the "online" aspect of this type of reporting is questionable.For this purpose OLAP was developed.

In the next article we will see how to create a analysis services(that is creating cube in OLAP) in .net

Have a happy coding..

BI IN SAP NETWEAVER 7.0

Purpose
The reporting, analysis, and interpretation of business data is of central importance to a company in guaranteeing its competitive edge, optimizing processes, and enabling it to react quickly and in line with the market. With Business Intelligence (BI), SAP NetWeaver provides data warehousing functionality, a business intelligence platform, and a suite of business intelligence tools with which an enterprise can attain these goals. Relevant business information from productive SAP applications and all external data sources can be integrated, transformed, and consolidated in BI with the toolset provided. BI provides flexible reporting, analysis, and planning tools to support you in evaluating and interpreting data, as well as facilitating its distribution. Businesses are able to make well-founded decisions and determine target-orientated activities on the basis of this analysis.
 

Integration with Other SAP NetWeaver Components
BEx Information Broadcasting allows you to publish precalculated documents or online links containing business intelligence content to the portal. The Business Explorer portal role illustrates the various options that are available to you when working with content from BI in the portal. For more information, see Information Broadcasting.

The BEx Broadcaster, the BEx Web Application Designer, the BEx Query Designer, KM Content, SAP Role Uploads, and the Portal Content Studio are used to integrate BI contents into the portal. For more information, see Integrating BI Content into the Portal.

The documents and metadata created in BI (metadata documentation in particular) can be integrated using the repository manager in knowledge management. The BI Metadata Repository Manager is used within BEx Information Broadcasting. For more information, see BI Document Repository Manager and BI Metadata Repository Manager.

You can use SAP NetWeaver Exchange Infrastructure (SAP NetWeaver XI) to send data from SAP and non-SAP sources to BI. In BI, the data is placed in the delta queue where it is available for further integration and consolidation. Data transfer using SAP NetWeaver XI is SOAP-based. For more information, see Data Transfer Using SAP XI.

Integration with BI Content Add-On
With BI Content, SAP delivers preconfigured role and task-based information models and reporting scenarios for BI that are based on consistent metadata. BI Content provides selected roles within a company with the information they need to carry out their tasks. The information models delivered cover all business areas and integrate content from almost all SAP and selected external applications. For more information, see BI Content.

Rounded Corners

When CSS3 is fully supported across browsers rounded corners will be as simple as:



.element {border-radius: 5px}

which will set a 5px radius on all 4 corners. For now we need some browser specific CSS combined with a little JavaScript to make this work in all browsers.


In Safari, Chrome, and other webkit browsers we use -webkit-border-radius and in Firefox and other Mozilla based browsers we use -moz-border-radius.



.element {
border-radius: 5px
-webkit-border-radius: 5px
-moz-border-radius: 5px
}

Webkit and Mozilla use different syntax when specifying one corner.



.element {
border-top-left-radius: 5px
-webkit-border-top-left-radius: 5px
-moz-border-radius-top-left
}

For non Webkit and Mozilla browsers a little jQuery plugin will mimic the border-radius property.



$(".element").corner("5px");

The jQuery corner plugin allows for more than setting the radius of the corner. You can also set the corner to show as a number of other patterns.

Web Developer

The Web Developer Extension is a extension for the Firefox browser and it's a great tool for web designers. It has a variety off essential tools that allow you to code quality websites and troubleshoot problems easily. It's a powerful all in one plugin. Web Developer extension adds a menu and a toolbar to the browser with various web developer tools. The added benefit of having Web Developer Tool is the ability to edit CSS on the fly. If you want to try a different font, different size, different color, background, borders, margins, padding, practically anything to do with CSS, you can make the changes in the Web Developer tool and see the changes instantly. The Web Developer tool saves you time when playing around with CSS.

Essential Firefox Add-ons - MeasureIt

As someone who creates designs for the Internet, one of the most challenging job is to create design elements aligned. In that case MeasureIt comes in handy and allows you to overlay a ruler on a browser page so you can verify width, height and alignment of page elements. With this beautiful extension you can measure distances between any two points on the page.

Essential Firefox Add-ons - ColorZilla

ColorZilla add-on features an online eyedropper, which makes it quite simple to get the exact value of a specific color. With ColorZilla you can get a color reading from any point in your browser, quickly adjust this color and paste it into another program. In addition to color picker, ColorZilla offers a DOM color analyzer which allows you to locate elements on the page that correspond to a given color and find out the CSS rules that specify a certain color. ColorZilla also features a online palette viewer that allows choosing colors from pre-defined color sets and saving the most used colors in custom palettes.

Essential Firefox Add-ons - Firebug

Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page. Firebug gives you full control over the CSS, HTML and JavaScript of any page that you choose. Inspect and edit HTML, Tweak CSS to perfection, Visualize CSS metrics, Monitor network activity, Debug and profile JavaScript, Quickly find errors, Explore the DOM, Execute JavaScript on the fly, Logging for JavaScript. Best of all, every change that you make is done live and instantly, so you can quickly test out different changes and see the results of those changes instantly.

Make 3D buttons view in CSS

3D CSS buttons are easy to create. The trick is to give your elements borders with different colors. Lighter where the light source shines and darker where it doesn't.
div#button {background: #888; border: 1px solid; border-color: #999 #777 #777 #999 }

The CSS above will create a button with the light source at the upper left. Usually one or two shades of color change is all that’s needed, but you can experiment for different effects.

Accessing parent documents in Flex

It will achieved by Application and Doccument object

Application object has the following characteristics:

* Application objects are MXML files with an <mx:Application> tag.
* Most Flex applications have a single Application object.
* The Application file is the first file loaded.
* An Application object is also a Document object.
* You can refer to the Application object as mx.core.Application.application from anywhere in the Flex application.
* If you load multiple nested applications by using the SWFLoader control, you can access the scope of each higher application by parentApplication.parentApplication, and so on.

Document object has the following characteristics:
* All MXML files that a Flex application uses are Document objects, including the Application object's file.
* Custom ActionScript component files are Document objects.
* The Flex compiler cannot compile a SWF file from a file that does not contain an <mx:Application> tag.
* Documents usually consist of MXML custom controls that you use in your Flex application.
* You can access the scope of a document's parent document by using parentDocument, parentDocument.parentDocument, and so on.
* Flex provides a UIComponent.isDocument property so that you can detect if any given object is a Document object.
Accessing Document and Application object scopes

mx.core.Application.application The top-level Application object, regardless of where in the document tree your object executes.

mx.core.UIComponent.parentDocument The parent document of the current document. You can use parentDocument.parentDocument to walk up the tree of multiple documents.

mx.core.UIComponent.parentApplication The Application object in which the current object exist

EXAMPLE:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComps="myComponents.*"
>
<mx:Script>
<![CDATA[

public function getSalutation():String {
return "Hi, " + mylbl.text;
}
]]>
</mx:Script>
<mx:Label  id="mylbl"  text="Guys"/>
<!-- Include the ButtonGetSalutation.mxml component. -->
<MyComps:ButtonGetSalutation/>

</mx:Application>

To access the mylbl(Label control) and call the getSalutation() method in your MXML components, you can use the application property, as the following example from the MyComponent.mxml component shows:

<?xml version="1.0"?>
<!-- containers\application\myComponents\ButtonGetSalutation.mxml -->
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">

<mx:Script>
<![CDATA[
/* To refer to the members of the Application class,
you must import mx.core.Application. */
import mx.core.Application;
]]>
</mx:Script>

<mx:Label id="myL"/>
<mx:Button label="Click Me" click="myL.text=Application.application.getSalutation();"/>
</mx:VBox>
Similarly use parentDocument.parentDocument.doSomething() for Document object.

Monday, November 29, 2010

SAP BI

What is SAP BI?

SAP BusinessObjects business intelligence (BI) solutions can empower your users to make effective, informed decisions based on solid data and analysis. All users, from the high-end analyst to the casual business user, can leverage business intelligence solutions to access to the information they need – with minimal dependence on IT resources and developers.

Sunday, November 28, 2010

Make use of toString() in Java

Every Java beginners must know about toString() method of java.lang.Object class. As you know java.lang.Object is the super most class in Java. Every pre-defined and user-defined class can override the methods available in the class java.lang.Object.

Of these, toString() method plays a vital role. See the following example:

int x = 100;
System.out.println(x);


This will print 100. Discuss the below example too:

class Student{
private String name;
public Student(String studentName){ name=studentName; }
private void setName(String name){ this.name=name; }
private String getName(){ return name; }
}


class ABC{
public static void main(String [] a){
Student s=new Student("Guru");
System.out.println(s);
}
}


Can you guess the output of the above program? Dirtily, it prints the object reference, not some meaningful information (such as student name, in this example). Now see this example:
class Student{
private String name;
public Student(String studentName){ name=studentName; }
private void setName(String name){ this.name=name; }
private String getName(){ return name; }
/** method overridden **/
public String toString(){ return name; }
}


class ABC{
public static void main(String [] a){
Student s=new Student("Guru");
System.out.println(s);
}
}


This prints Guru. So, overriding toString() method improves your object quality and very very helpful when you directly pass or print object.

Ruby Symbols Description

Matter related to the old and new Ruby programmer, and Ruby's symbols are confusing sometimes or always. Smoothly before this, can not get used is pretty. People learn about the Ruby language is often Rubionreiruzu learn from the project. The Rubionreiruzu symbol is everywhere. There really is everywhere. So, pay attention to the concept of a symbol of ruby, it's important to remember that.
Ruby is an instance of a symbol of class symbol. Put before the identifier symbol following the colon, ": name", ": id" or ": user". Ruby Symbol class includes a method of a class.




  1. all_symbols - Returns an array of all the symbols currently in Ruby’s symbol table.

  2. id2name - Returns the name or string corresponding to sym:, name.id2name the "name" back.

  3. inspect - Literally back to the symbol.

  4. to_i - Return a unique integer to each symbol. This method never raises an exception.

  5. to_s - id2name as same. Returns the string.

  6. to_sym - Returns the symbol corresponding to string.

Debugging Rails

You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that "tail –f" commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information will also be displayed in the browser on requests from 127.0.0.1.

Using the Ruby logger class from inside your controllers, you can also log your own messages directly into the log file from your code like:
class ReportController < ActionController::Base

def destroy

@report = Report.find(params[:id])

@report.destroy

#Debug Log file

logger.info("#{Time.now} Destroyed Report ID ##{@report.id}!")

end

end

These are the available log levels, :debug, :info, :warn, :error, and :fatal, corresponding to the log level numbers from 0 up to 4 respectively.

Description:


logger.debug

The DEBUG level designates fine-grained informational events that are most useful to debug an application.

logger.info

The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.

logger.warn

The WARN level designates potentially harmful situations.

logger.error

The ERROR level designates error events that might still allow the application to continue running.

logger.fatal

The FATAL level designates very severe error events that would presumably lead the application to abort.

To write in the current log use the logger.(debug|info|warn|error|fatal) method from within a controller, model or mailer.
The default Rails log level is info in production mode and debug in development and test mode.

Finders are great but be careful

Finders are very pleasant to use, enable you to write readable code and they don’t require in-depth SQL knowledge. But the nice high level abstraction come with a computational cost.


Follow these rules of thumb:





  1. Retrieve only the information that you need. A lot of execution time can be wasted by running selects for data that is not really needed. When using the various finders make sure to provide the right options to select only the fields required (:select), and if you only need a numbered subset of records from the resultset, opportunely specify a limit (with the :limit and :offset options).

  2. Don't kill your database with too many queries, use eager loading of associations through the include option:
    Avoid dynamic finders like MyModel.find_by_*. While using something like User.find_by_username is very readable and easy, it also can cost you a lot. In fact, ActiveRecord dynamically generates these methods within method_missing and this can be quite slow. In fact, once the method is defined and invoked, the mapping with the model attribute (username in our example) is ultimately achieved through a select query which is built before being sent to the database. Using MyModel.find_by_sql directly, or even MyModel.find, is much more efficient.

  3. Be sure to use MyModel.find_by_sql whenever you need to run an optimized SQL query. Needless to say, even if the final SQL statement ends up being the same, find_by_sql is more efficient than the equivalent find (no need to build the actual SQL string from the various option passed to the method). If you are building a plugin that needs to be cross-platform though, verify that the SQL queries will run on all Rails supported databases, or just use find instead. In general, using find is more readable and leads to better maintainable code, so before starting to fill your application with find_by_sql, do some profiling and individuate slow queries which may need to be customized and optimized manually.


Optimize your Ruby code

This may seem obvious, but a Rails application is essentially ruby code that will have to be run. Make sure your code is efficient from a Ruby standpoint. Take a look at your code and ask yourself if some refactoring is in order, keeping in mind performance considerations and algorithmic efficiency. Profiling tools are, of course, very helpful in identifying slow code, but the following are some general considerations (some of them may appear admittedly obvious to you):





  1. When available use the built-in classes and methods, rather than rolling your own;

  2. Use Regular Expressions rather than costly loops, when you need to parse and process all but the smallest text;

  3. Use Libxml rather than the slower REXML if you are processing XML documents;

  4. Sometimes you may want to trade off just a bit of elegance and abstraction for speed (e.g. define_method and yield can be costly);

  5. The best way to resolve slow loops, is to remove them if possible. Not always, but in a few cases you can avoid loops by restructuring your code;

  6. Simplify and reduce nested if/unless as much as you can and remember that the operator ||= is your friend;

  7. Hashes are expensive data structures. Consider storing the value for a given key in a local variable if you need to recall the value a few times. More in general, it’s a good idea to store in a variable (local, instance or class variable) any frequently accessed data structure.


Group operations in a transaction

ActiveRecord wraps the creation or update of a record in a single transaction. Multiple inserts will then generate many transactions (one for each insert). Grouping multiple inserts in one single transaction will speed things up.


Insead of:




 my_collection.each do |q|
Report.create({:phrase => q})
end


Use:




Report.transaction do
my_collection.each do |q|
Report.create({:phrase => q})
end
end



or for rolling back the whole transaction if any insert fails, use:




Report.transaction do
my_collection.each do |q|
report = Report.new({:phrase => q})
report.save!
end
end

Saturday, November 27, 2010

IBM DB2 Security Mechanisms

For every e-business solution, the company should give more sound for database security. The database security plan should define:


  • who is allowed to the instance and/or database

  • where and how a user's password will be verified

  • authority level that a user is granted

  • commands that a user is allowed to execute

  • data that a user is allowed to read and/or alter

  • database objects a user is allowed to create, alter, and/or drop



DB2 Security Mechanisms

There are 3 main mechanisms within DB2 that allow a DBA to implement a database security plan:

  1. Authentication

  2. Authorization

  3. Privileges


1. Authentication

Authentication is the first security feature you'll encounter when you attempt to access a DB2 instance or database. It works closely with the security features of the underlying operating system to verity the user IDs and passwords. It can also work with security protocols like kerberos to authenticate users.

2. Authorization

It involves determining the operations that user and/or groups can perform, and the data objects that they may access. An user's ability to perform high level database and instance management is determined by the authorities that they have been assigned. The 5 different authority levels within DB2 are

  1. SYSADM

  2. SYSCTRL

  3. SYSMAINT

  4. DBADM

  5. LOAD


3. Privileges

A bit more granular than authorities, and can be assigned to users and/or groups. It defines the commands that a user can use to access objects like tables, views, index and packages.

Locate ASP.Net AJAX AutoCompleteExtender inside TabContainer

ASP.Net Ajax contains rich array of controls used to create an interactive Web experience.While creating a ajax website you might face problems in binding two controls.For example locating AutoCompleteExtender inside the tab Container.Let us see how to solve this above problem.


1.   First, create the a script manager in your .aspx page.like this,


<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>


As a server-side control, ScriptManager reacts to events in the ASP.NET page life cycle and uses those events to coordinate the activities of all the controls, options, and code employed by ASP.NET AJAX.


2.   Create the Tab Container,inside it create one or more Tab Panel like


<cc1:TabContainer ID="Container1" runat="server"  ActiveTabIndex="1" >


<cc1:TabPanel ID="tpanel1" runat="server" HeaderText="Sample Tab">


<ContentTemplate>


//place other controls here(Eg:labels,buttons,textboxes,etc..)</ContentTemplate>


</cc1:TabPanel>


</cc1:TabContainer>


3.  Here AutoCompleteExtender is also acting as a controls of tpanel1,So your will be look like this


<cc1:TabContainer ID="Container1" runat="server"  ActiveTabIndex="1" >


<cc1:TabPanel ID="tpanel1" runat="server" HeaderText="Sample Tab">


<ContentTemplate>


//place other controls here(Eg:labels,buttons,textboxes,etc..)  including the textbox(txt_sample)


//here is the code for autocompleteextender


<cc1:AutoCompleteExtender ID="AutoCompleteExtender1"  runat="server" ServiceMethod="GetCompletionList1"
DelimiterCharacters="" Enabled="True" ServicePath="" CompletionInterval ="500" MinimumPrefixLength="1"
UseContextKey="True"  TargetControlID="txt_sample" >
</cc1:AutoCompleteExtender>


</ContentTemplate>


</cc1:TabPanel>


</cc1:TabContainer>


4. Create a Service Method in .cs page for working with autocomplete textbox.


Have a  Happy Coding...


Configuring JNDI data source in Tomcat

By using Java Naming and Directory Interface (JNDI) service, one can connect resources of different technologies.

A typical web application in Tomcat has a file called as context.xml in which the context path (root) of the web application is defined. Usually this file is located in META-INF directory of you web application (see figure 1). You can configure a JNDI data source in Tomcat by adding a declaration for your resource to this file. This is the application's context container, which enables you to specify application meta-data necessary for the server in order to deploy and run the application. There are various locations where you can specify context elements, such as your server's global i.e. tomcat-install-dir/conf/context.xml

[caption id="attachment_109" align="alignnone" width="264" caption="Figure 1: META-INF/context.xml"]context.xml[/caption]

Add the following Resource tag as a declaration for the JNDI resource. The code below is an example of how you can declare JNDI resource for MySQL database.

<?xml version="1.0"?>
<Context path="/abc">
<Resource name="jdbc/jndi-name"
auth="container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="yourusername"
password="yourpassword"
driverClass="com.mysql.jdbc.Driver"
url="jdbc:mysql://hostname:3306/databasename" />
</Context>

Friday, November 26, 2010

Prototyping Visualization

if you want to design a website or user interface for a website, one of the fundamental things to do is to make sure you have the interface designed well before you start building. The most general way to plan an interface are to use Wireframes.

Wireframes are line drawings, comparable to blueprints, which demonstrates the general navigation and the building blocks e.g. content, functionality etc. that will go into making of the website. The main rationale behind creating Wireframes is to sustain the flow of your particular logical and business functions by classifying all the entrance and exit points for every single page of your website.

Wireframes can be created manually on a paper. It is the easiest and fastest way of creating Wireframes. When time is short just put your layout ideas on a paper with a focus on what elements should go where.

Wireframes are crucial component of the initial development stage as they generate user expectations and help to boost the understanding and flow of a website by increasing acquaintance with the site.

During the creation of the project, Wireframes function as a firm and established base on which to consider changes and new requirements. Common page structure and content needs for individual web pages are easily conveyed using Wireframes.

Wireframes mostly lead to a better output in terms of superior product because they are also immensely helpful in getting valuable and accurate input.

Wireframes/Prototyping makes it easy to compare and evaluate different ideas and rival designs, which further makes it easier to incorporate changes.

Development cost and time are ultimately cut down by sizeable amount by getting a signoff on a detailed Wireframes because programmers making never-ending changes to their code have become a passe.

Some people prefer Visio, Adobe Illustrator, Photoshop, Freehand, Fireworks, and of course even PowerPoint, Dreamweaver, Adobe Indesign etc.

But the following are some of the other tools, which are less popular but have good stuff.

Dia
Website Wireframes Tools
Oversite
Gliffy
Protoshare
Jumpchart
Pencil
Denim

Wednesday, November 24, 2010

Find out IP address

We can get the IP address of any visitor by using PHP. Finding the IP address is very important requirement for many scripts where we store the members or visitors details. For security reason we can store IP address of our visitors who are doing any purchases or recording the geographical location of the visitor can be done this way. Some time based on the IP address we can redirect the browser to different areas of the site. There are many applications using this and here is the PHP code to know the IP address of any visitor to the site.
<?php
//Get IP Address
$ip = $_SERVER['REMOTE_ADDR'];
echo "<b>IP Address= $ip</b>";
?>

Tuesday, November 23, 2010

Send HTML Mail With PHP

Sending html email in php is extremely easy. All you have to do is call the “mail” function with some extra header.

Have a look on example:
<?php
//define the receiver of the email
$to = 'youraddress@example.com';

//define the subject of the email
$subject = 'Test HTML email';

//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";

//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";

//define the body of the message.
ob_start(); //Turn on output buffering
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>

echo $random_hash;

//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();

//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );

//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

Single quotes, Double quotes

It’s easy to just use double quotes when concatenating strings because it parses everything neatly without having to deal with escaping characters and using dot values. However, using single quotes has considerable performance gains, as it requires less processing.

For Example:
<?php
//Consider this string
$howdy = 'everyone';
$foo = 'hello $howdy';
$bar = "hello $howdy";

// Concatenating this strings
$howdy = 'everyone';
$foo = 'hello $howdy';
$bar = "hello $howdy";
?>

$foo outputs to “hello $howdy” and $bar gives us “hello everyone”. That’s one less step that PHP has to process. It’s a small change that can make significant gains in the performance of the code.

Scripts Execution Time Limits

Putting a time limit on your PHP scripts is a very critical thing. There are times when your scripts will fail, and when they do, you’ll want to use the set_time_limit function to avoid infinite loops and database connection timeouts. The set_time_limit puts a time limit on the maximum number of seconds a script will run (the default is 30). After that time period, a fatal error is thrown.

Increase PHP Script Execution Time Limit

Every once in a while we need to process a HUGE file. Though PHP probably isn't the most efficient way of processing the file, we usually use PHP because it makes coding the processing script much faster. To prevent the script from timing out, I need to increase the execution time of the specific processing script.

How to fix
<?php
//300 seconds = 5 minutes
ini_set('max_execution_time', 300);
?>

Place this at the top of your PHP script.

UBUNTU the Best Linux Desktop Distribution

There are a lot of Linux distributions that have the primary focus of becoming the next best desktop replacement for Windows or OS X. Canonical's UBUNTU is the great and most contentious group of distro which offers 4 kinds of desktop and special edition for laptops and Live Distros. you can download ubuntu from the following link Download.

Ubuntu edges out its closest contenders, Fedora and openSUSE, because its development team is constantly focused on the end-user experience. Canonical and the Ubuntu community have spent a lot of time and resources on bringing ease-of-use tools to this distribution, particularly in the area of installing Ubuntu and installing applications within Ubuntu.

In addition, Ubuntu's level of support for its desktop products is highly superior, which is important in this class of distributions since it is the most likely to contain users new to Linux. Both the official and unofficial Ubuntu documentation is robust and searchable, a big plus.

Linux and its Advantages

Linux is an operating system that was initially created as a hobby by a young student, Linus Torvalds, at the University of Helsinki in Finland. Linus had an interest in Minix, a small UNIX system, and decided to develop a system that exceeded the Minix standards. He began his work in 1991 when he released version 0.02 and worked steadily until 1994 when version 1.0 of the Linux Kernel was released. The kernel, at the heart of all Linux systems, is developed and released under the GNU General Public License and its source code is freely available to everyone. It is this kernel that forms the base around which a Linux operating system is developed. There are now literally hundreds of companies and organizations and an equal number of individuals that have released their own versions of operating systems based on the Linux kernel. More information on the kernel can be found at our sister site, LinuxHQ and at the official Linux Kernel Archives.

Apart from the fact that it's freely distributed, Linux's functionality, adaptability and robustness, has made it the main alternative for proprietary Unix and Microsoft operating systems. IBM, Hewlett-Packard and other giants of the computing world have embraced Linux and support its ongoing development. Well into its second decade of existence, Linux has been adopted worldwide primarily as a server platform. Its use as a home and office desktop operating system is also on the rise. The operating system can also be embedding into electronic devices such as routers, atm machines etc.



  1. Linux is not only a free operating system. but it also provides free software for everyone.

  2. Linux is virus free operating system.

  3. Linux is Hiperformance sclable and stable

  4. Compatable with atmost all drivers.

  5. Update all your software with a single click.

  6. No need to use software illegally coz linux comes with a huge package of softwares which is larger than windows.

  7. even if u need new software, Don't searching the web, Linux installer gets it for you.

  8. Linux provides the next generation of desktops.

  9. you can customise your desktop.

  10. No back doors in your software.

  11. Enjoy free and unlimited support.

  12. customise your start menu.

  13. you can use MSN, GTalk, Yahoo, AIM, ICQ, Jabber, with a single program.

  14. Keep an eye on the weather using widgets.

  15. Linux works in minamal hardware support


Most people think linux is hard to learn. but it is easy then windows. why dont just give a try on the free software. MINT and Ubuntu would be a good distrubtion for start using computers.

Monday, November 22, 2010

Refresh / Redirection

When you need your web page automatic refresh in 5 second or any second, use this meta tag.  It's a simple code, put it between HEAD tag in your web page. This script easy but powerful.
<HEAD>
<meta http-equiv='refresh' content='2;url='file_name or URL'>
</HEAD>
// content = time (second)
// file_name = name of file you want to refresh or redirect

Many websites use this scripts to redirect to another page or refresh the same page.

For example:  My website updates in every 10 minutes and I want to show user my latest content then I put this script to my page and set it refreshs in every 10 minutes

cURL Function

cURL is a library which allows you to connect and communicate to many different types of servers with many different types of protocols. Using cURL you can:

  • Implement payment gateways’ payment notification scripts.

  • Download and upload files from remote servers.

  • Login to other websites and access members only sections.


PHP cURL library is definitely the odd man out. Unlike other PHP libraries where a whole plethora of functions is made available, PHP cURL wraps up a major parts of its functionality in just four functions.

A typical PHP cURL usage follows the following sequence of steps.

curl_init – Initializes the session and returns a cURL handle which can be passed to other cURL functions.

curl_opt – This is the main work horse of cURL library. This function is called multiple times and specifies what we want the cURL library to do.

curl_exec – Executes a cURL session.

curl_close – Closes the current cURL session.

Below are some examples which should make the working of cURL more clearer.

Download file or web page using PHP cURL


The below piece of PHP code uses cURL to download Google’s RSS feed.
<?php
/**
* Initialize the cURL session
*/
$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss');
/**
* Ask cURL to return the contents in a variable
* instead of simply echoing them to the browser.
*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/**
* Execute the cURL session
*/
$contents = curl_exec ($ch);
/**
* Close cURL session
*/
curl_close ($ch);
?>

As you can see, curl_setopt is the pivot around which the main cURL functionality revolves. cURL functioning is controlled by way of passing predefined options and values to this function.

The above code uses two such options.

  • CURLOPT_URL: Use it to specify the URL which you want to process. This could be the URL of the file you want to download or it could be the URL of the script to which you want to post some data.

  • CURLOPT_RETURNTRANSFER: Setting this option to 1 will cause the curl_exec function to return the contents instead of echoing them to the browser.


Download file or web page using PHP cURL and save it to file


The below PHP code is a slight variation of the above code. It not only downloads the contents of the specified URL but also saves it to a file.
<?php
/**
* Initialize the cURL session
*/
$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss');
/**
* Create a new file
*/
$fp = fopen('rss.xml', 'w');
/**
* Ask cURL to write the contents to a file
*/
curl_setopt($ch, CURLOPT_FILE, $fp);
/**
* Execute the cURL session
*/
curl_exec ($ch);
/**
* Close cURL session and file
*/
curl_close ($ch);
fclose($fp);
?>

Here we have used another of the cURL options, CURLOPT_FILE. Obtain a file handler by creating a new file or opening an existing one and then pass this file handler to the curl_set_opt function.

cURL will now write the contents to a file as it downloads a web page or file.

Sunday, November 21, 2010

PHP sessions problem

Below are some of the common problems faced by beginners while using sessions in PHP.

Headers already sent


This is the most commonly faced error is also the easiest to fix. Lets first see what a typical HTTP response looks like.

As can see from the image headers always precede (come before) the content. The “headers already sent” error occurs when you call session_start after you have already sent some content to the browser. Event an empty line at the start of the file is considered as content and will cause error.

set Session


How to fix

  1. Ensure that there is no empty line or HTML comments before the call to session_start function

  2. Add ob_start at the start of the file. A call to ob_start causes the output of the server to be buffered, that is stored in memory. While output buffering is active no output,except the headers, is sent from the script. The output is stored in the buffer and sent to the browser at the end of the script. You can also send the buffer’s contents to the browser by calling ob_flush or ob_end_flush


<?php
//Start bufferng the output
ob_start();
print("Some text");
//Since the output is now buffered,
//the above statement will not cause any error
session_start();
?>

Calling session_start multiple times


It is possible that session_start might get called multiple times by way of include files. This will not break you script but it might, depending on your error reporting settings, display a notice on your browser.

Multiple calls to session_start will result in an error of level E_NOTICE. Only the first call to session_start will be effective and all subsequent calls will be ignored.

Set error reporting level to maximum

Configure your development environment to display all PHP warnings, notices and errors. This will help you code better and also help in catching potential bugs early in development phase.

You can change the error reporting level at runtime by adding the following code at the top of your PHP script:
<?php
// Report all PHP errors.
// Don't enable on production servers
error_reporting(E_ALL);
?>

You can also control whether you want to display errors in the browser itself or whether you want to log the errors.

Note: Displaying errors is not recommended for production servers.

SQL injections / Escape special characters like ',",\

In the simplest case, special characters may simply break your query. In a more extreme case, a hacker might use SQL injections to gain access to your application. So it is important that we escape these special characters with a \ (backslash). That is, insert a backslash before each special character.

We can escape special characters (prepend backslash) using mysql_real_escape_string or addslashes functions. In most cases PHP will this do automatically for you. But PHP will do so only if the magic_quotes_gpc setting is set to On in the php.ini file. We first check whether this setting is on or not. If the setting is off, we use mysql_real_escape_string function to escape special characters. If you are using PHP version less that 4.3.0, you can use the addslashes function instead.
A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated.

If the magic quotes setting is on, we do not need escape special characters since PHP has already done it for us. We can check the magic_quotes_gpc by using get_magic_quotes_gpc function.
<?php
if(!get_magic_quotes_gpc()) {
$login=mysql_real_escape_string($_POST['login']);
}else {
$login=$_POST['login'];
}
?>