JSP Application with NetBeans IDE


To develop a JSP application on netbeans we require Netbeans IDE. In this application we used NetBeans 7.0. This IDE provide many facilities like in built web server (glassfis, tomacat) or datasource(java db). These are the steps we follow to develop an application on netbeans.

Step 1: Creating a new New Project

 
In first step we select the new project option from file menu.

newproject.jpg

Step 2: Creating a new Web Application

In this step we select web application option and then click on next button.

selectjavawebapp.jpg

Step 3:  Giving Name and Location

In this application we give it a specific name and set location of the project, and click on the next button.

name and location.jpg

Step 4: Select Sever and setting the server

In this step we select a server , in this project we select server GlassFish Server 3.1 and Java EE 6 Web version and click on the next button.

select server.jpg

Step 5: Select Frameworks

For simple jsp application there is no need to select any application then just click on the Finish button.

framework.jpg

Step 6: First view of jsp starting page

The following figure is the home page of jsp page now we are starting the coding on it.

firstpage u see.jpg

Example

Here we create three basic jsp programme to explain the jsp concept with netbeans.

Index.jsp

<HTML>
<HEAD>
<TITLE>Creating An JSP Appliocation with NetBeans</TITLE>
</HEAD>

<BODY bgcolor="cyan">
<H1>Creating An JSP Appliocation with NetBeans</H1>
<%
double accounts[];
accounts = new double[200];
accounts[4] = 5555.853;

out.println("Account 4 holds $" + accounts[4]);
%>
</BODY>
</HTML>


Home.jsp

<HTML>
<HEAD>
<TITLE>Hi Friends my self is vikas</TITLE>
</HEAD>
<BODY bgcolor="green">
<H1>Getting Parameter Names<H1>
<FORM ACTION="formAction.jsp" METHOD="POST"><pre>
<b>Name</b>:<INPUT TYPE="TEXT" NAME="t1">
<SELECT NAME="select" SIZE="5" MULTIPLE>
<OPTION>1</OPTION>
<OPTION selected>2</OPTION>
<OPTION> 3</OPTION>
<OPTION>4</OPTION>
<OPTION>5</OPTION>
</SELECT>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM></pre>
</BODY>
</HTML>

formAction.jsp

<HTML>
<HEAD>
<TITLE>
Now We Are Reading Parameter</TITLE>
</HEAD>
<BODY bgcolor="pink">
<H1>Reading Parameter</H1>
Parameter Names:
<BR>
<% java.util.Enumeration names = request.getParameterNames();
while(names.hasMoreElements()){
out.println(names.nextElement() + "<BR>");
}
%>
</BODY>
</HTML>

Run the application

Now we compile and run the application (Shift +F6) we found the output as.

Index.jsp

index.jsp.jpg

Home.jsp
 

home.jsp.jpg

formAction.jsp

parameter.jsp.jpg

Perhaps this article helps to understand the jsp application with NetBeans IDE.

Up Next
    Ebook Download
    View all
    Learn
    View all