I have used lot of IDE’s but the complete IDE for me is NetBeans , NetBeans is completely free and available for download at http://netbeans.org . NetBeans is a complete opensource IDE with many plugins and has support for many popular languages like PHP and Jruby and Ruby on rails.
This blog entry would be dedicated to JAVA language and how to create simple web applications in JSP and ServletsIn Netbeans there is support for JSF 1.x and 2.0 ,struts 1.3.8 , springs web MVC , hibernate 3.2.5 ;below I have shown how to create a simple application with JSP and servlet. To make your life simple there is a “palette” for HTML which you can use in your JSP’s, HTML, facelets , if it is not coming then you can add it by going to “window” button in the top bar and clicking on palette option in it.
How to create a simple web application in JSP and Servlets using netbeans 6.9.
|Go to “File> New Project” in top menu and click on it and you would see the below screen :|
|Click on the “Java Web” and then go onto “Web Application” and then finally click on the “next” button and you would see the below image|
|In the above “Project Name” I have taken TestProject as the name of the project and the project would be stored in the “Project Location” directory , the “set as main project” checkbox is clicked so as to make the project a top priority while running or debugging it. Now when you click on “Next” you would get the below image|
|Now in the above image I have chosen Server for this application as “Glass Fish Server 3.1” which comes bundled with NetBeans and is the default server for “Netbeans” , there is also provision to add other servers in NetBeans like Tomcat ,weblogic,jboss etc.I have chosen Java EE 6 Web , as j2ee 6 is possible in GlassFish v3 server.Finally click on “Next” button and you would get the below image|
|The above box is asking for which framwork you want to add in your application as we are making a simple web application comprising of “servlets” and “jsp” , hence we don’t require any framework.Finally click “Finish” and done the project is added in your NetBeans project list and ready for development , you would see the below image in the project explorer:|
|In the above project Explorer you have got a “index.jsp” page as the default starting page (can change it in the web.xml) located in your WEB-INF folder.your JDK and Glassfish server JAR files would be added automatically. I have added a Servlet in the project by right clicking on the project and clicking on the “servlet” option , you would get the below options when adding a servlet in your project|
|The above box creates a NewServlet in your project , then click on “Finish” and you would get the below box|
|In the above box you would get a “add information to deployment descriptor(web.xml)” checkbox just click on it and it would serve two purpose for you create a web.xml for you and add the url mapping of the servlet in web.xml automatically “/NewServlet” is taken as the mapping for the above servlet.Finally click on finish and that would add the servlet in your project, Now you know how to add servlet and JSP would follow a similar trend.|
|Now as every thing is in place just press “shift+f6” and that would run the project in your default browser, as index.jsp is the welcome page you would get the view of index.jsp on the browser.|