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.
Step 2: Creating a new Web Application
In this step we select web application option and then click on next button.
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.
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.
Step 5: Select Frameworks
For simple jsp application there is no need to select any application then just
click on the Finish button.
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.
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
Home.jsp
formAction.jsp
Perhaps this article helps to understand the jsp application with NetBeans
IDE.