Monday, July 7, 2008

Struts 1.2 validator framework tutorial

Hey guys I search for this topic but i couln't find a simple tutorial for this topic.

so i thought to post what i know on this...

i recomend u to practice Struts basics tutorial on before this Netbeans official site.

1. new project>web>web application
2.struts1.2.9 JSP>anyname
i named mine as 'sampleJSP.jsp'

4.add html taglib
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="h" %>

5. Add a form tag to JSP using tag lib
< action=" " onsubmit=" ">
< property="name">
< value="OK">
< / html:form>
6.Create New StrutsActionForm
*important: superclass should be org.apache.struts.validator.ValidatorForm

7. Make getters and setters for text field in JSP

(if u create a propety called 'name' you dont need to do this, bcoz
Netbeans defaultly create for String 'name and int 'number'
8.Create New StrutsAction
*important: Action path should be same as JSP forms action
(the Action path you give here can give in JSP)

9.edit validation.xml

< name="NameForm">
< property="name" depends="required">
< key="">
< /field>

< /form>

10.add '' to properties file

11.Add these to JSP page
< formname="NameForm">
< /head>

< action="name" onsubmit="return validatenameForm(this);">

12. Add Server side validation to work in browsers where javascript doesn't work

< html:errors/>

Final view of sampleJSP...

12. Now run your application

try it and comment plz...

Monday, April 7, 2008

"Shared Library" functionality in NetBeans 6.1 beta

In new NetBeans 6.1-beta When creating a project you now get the offer to enable "sharable

When enabling this feature you are asked to specify the location where the libraries should be

saved. By default it will suggest ..\libraries, which is a bit strange considering that it is

outside the project folder.

NetBeans Day 2008

NetBeans Day San Francisco 2008 at the CommunityOne Conference

Monday, May 5, 2008
9:30 am - 6:00 pm
Moscone Center,

San Francisco, California
Register now

Wednesday, April 2, 2008

Little NetBeans IDE 6.1 Beta

The NetBeans IDE is a modular, standards-based, integrated development environment (IDE) written in the Java programming language. The NetBeans project consists of an open source IDE and an application platform, which can be used as a generic framework to build any kind of application.

Noticed Favorite Features....

* JavaScript;

o Semantic Highlighting

o Code Completion and Type Analysis
tutorial on official site

* Performance Enhancements;

o Up to 40% faster startup

* New MySQL Support in Database Explorer

o Register MySQL servers

o View, create, and delete databases

o Easy launch of the administration tool for MySQL

* Java Beans;

o Bean Patterns in Navigator

o Generate Bean Property

o BeanInfo Editor

Thursday, March 6, 2008

Setting up a JDBC Connection Pool

In order to specify how the web server allows an application to communicate with the database, we need to set up a database connection pool. A database connection pool is basically a group of reusable connections that a server maintains for a specific database. Web applications requesting a connection to a database obtain that connection from the pool. When an application closes a connection, the connection is returned to the pool.

In order to set up a connection pool on the server, a JDBC resource (also called a data source) must first be created. A JDBC resource provides applications with a connection to a database. Depending on whether you're using Tomcat or SJSAS, do the following:

see more here

How to RENAME a Java package...

if the 'package' statement at the top needs to change..

1.Projects > Source Packages > (Expand)
2.Right-click > Refactor > Rename
new name-new package name
4.Next > Refactor

Wednesday, March 5, 2008

Creating a connection to a Database:

1. In the Services window choose 'Connect Using' from the right-click menu of the driver you just added. The New Database Connection dialog opens. see.....

2. In the Basic Setting tab, enter the Database's URL in the corresponding text field. The URL is used to identify the type and location of a database server. In this example, you need to specify the host name (i.e. the location of the server), the port number on which the database communicates, and the name of the database instance being used. In this case you can enter: jdbc:mysql://localhost:3306/MyNewDatabase
3. For User Name and Password, enter root, and nbuser respectively:

New Database Connection dialog containing connection details
4. Click OK, then click OK again to exit the dialog. A new Connection node displays in the Runtime window's Database explorer under the Databases node:

new connection node displayed in database explorer

You are now connected to MyNewDatabase in the IDE. Note that the new connection node icon appears whole when you are connected to a database. Likewise, it appears broken when there is no connection.

At later stages, when working with databases through the Database explorer, you may need to manually connect to a database. You can do so by right-clicking the broken database connection node and choosing Connect.

Registering the Database in NetBeans IDE

Now that you have the database server installed and configured, and have created a new database, you can register the MySQL server in NetBeans IDE. Begin by examining the functionality offered by the Database explorer located in the IDE's Runtime window (Ctrl+5). The Database explorer is represented by the Databases node (database node icon). From this interface you can connect to databases, view current connections, add database drivers, as well as create, browse or edit database structures.

You can use the Database explorer to register MySQL in the IDE. There are two simple steps that need to be performed:

1. Adding the Driver to the IDE
2. Creating a Database Connection

Adding the Driver to the IDE

In order to allow NetBeans IDE to communicate with a database, you need to employ a Java-based driver. Generally speaking, drivers in NetBeans IDE use the JDBC (Java Database Connectivity) API to communicate with databases supporting SQL. The JDBC API is contained in the java.sql Java package. A driver therefore serves as an interface that converts JDBC calls directly or indirectly into a specific database protocol.

In this tutorial, you are using the MySQL Connector/J driver, which is a pure Java implementation of the JDBC API, and communicates directly with the MySQL server using the MySQL protocol. To add the driver to the IDE:

1. If you have just downloaded the driver, first extract it to a location on your computer. Set the root directory to: C:\mysql-connector-java-5.0.5.
2. In the IDE, in the Database explorer from the Runtime window (Ctrl+5) expand the Databases node and right-click the Drivers node. Choose New Driver. The New JDBC Driver dialog opens.
3. Click the Add button in the top right corner. Navigate to the driver's root directory and select the driver's jar file (e.g. mysql-connector-java-5.0.5-bin.jar). Click Open. The New JDBC Driver dialog should look like this:

New JDBC Driver dialog containing driver details
4. Click OK. In the Runtime window expand the Databases > Drivers nodes and note that a new MySQL driver node is displayed:

new driver node displayed in database explorer

Note: While you just made the database driver available to the IDE, you have not yet made it available to any specific application. At this stage, you can use the IDE to access and modify the database, but cannot do so from an application yet.

***********more at netbeans official site

Switch From Uppercase to Lowercase

  • Ctrl-U, then U Convert selection to uppercase

  • Ctrl-U, then L Convert selection to lowercase

  • Ctrl-U, then S Toggle case of selection

Switch through files(Tabs) in the Editor

  1. Call up the list of all open tabs in the Editor by by pressing Ctrl-Tab while keeping the ctrl key pressed.
  2. Still with the ctrl key pressed, browse through the list of open tabs by hitting Ctrl-Tab; browse backwards through the list with Shift-Ctrl-Tab. Releasing the keys switches to the selected tab.
  3. Pressing Ctrl-Tab once and then letting both keys go immediately, will switch directly back to the previous tab used.
Note however, that in some operating systems, Ctrl-Tab is already associated with another conflicting action. In this case, use Ctrl-~ instead.

Tuesday, March 4, 2008

Compare Two Files in Netbeans6

  1. In the Projects tab, click and select with the ctrl key pressing two files.
  2. Right-click one of the selected files, and select Tools > Diff from the context menu.
  3. The graphical Diff view appears and lets you step through all differences.
Diffrent code blocks will be selected in different colors...

this is very important when you want to edit a file..
clone the orginal document(Rgt on doc tab>Clone Document) and edit.. then compare...

Note :

Diff only appears in the Tools menu when two files are selected and in focus.

Monday, February 18, 2008

Usin the "Palette" for design in JSP

1.Choose File > New Project (Ctrl-Shift-N) from the main menu.
Under Categories, select Web. Under Projects,
select Web Application then click Next.

2.Specify the Project Location to any directory on your computer.

3.focus the index.jsp file


5.drag a Form item to a point after the 'h2'tags into the Source Editor

6.see the image
Specify the following values:

* Action: targetjsp.jsp
* Method: GET
* Name: anyname

7.Drag a Text Input item to a point just before the < /form> tag

8.Use other palette items for your needs...

Sunday, February 17, 2008

How to add a code templates in "Netbeans"..

this is simply means using 'abbreviations' for
commonly code segments.

1.first try default abbrevation
in a java application 'psvm' and press 'tab' key
it will turn in to...

public static void main (String[] args) {


2.Go to,
Tools>Options>Editor>Code Templates

3.Select your language

4.New>(type your abbrv-eg'sop')>OK

5.Type the code


further.. set the cursor point
type code like this


notice the pharse--${cursor}

Thursday, February 14, 2008

JSP pages


< html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
< title>JSP Page< /title>
< /head>
< body>
< h2>Entry Form..< /h2>< form name=" Name Input Form" action="response.jsp">
Enter your name:
< input type="text" name="name" value="" />
< input type="submit" value="OK" />
< /form>
< /body>
< /html>

(2)responsing JSP file(response.jsp)

< html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
< title>JSP Page< /title>
< /head>
< body>
< jsp:useBean id="mybean" scope="session" class="" />
< jsp:setProperty name="mybean" property="name" />
< h2>Hello, !< /h2>
< /body>
< /html>



public class NameHandler {

private String name;
public NameHandler(){
name = null;

public String getName() {
return name;

public void setName(String name) { = name;

***(1)Setting Up the Project

Start NetBeans IDE.
In the IDE, choose File > New Project
In the New Project wizard, select Java Application
Then click Next.
In the Name and Location page of the wizard, do the following
In the Project Name field, type HelloWorldApp.
In the Create Main Class field, type helloworldapp.HelloWorldApp
Leave the Set as Main Project checkbox selected.

// TODO code application logic here

* Save the change by choosing File > Save.

* Compiling the Source File--F11
To compile your source file, choose Build > Build Main Project from the IDE's main menu.

* Running the Program--F6
From the IDE's menu bar, choose Run > Run Main Project.