1 / 9

Java Servlets example using NetBeans 6

Java Servlets example using NetBeans 6. Pre-requirements:. Install Java JDK 1.6 Install NetBeans IDE 6 (we will use version NetBeans IDE 6.7.1 update 16) Remember to choose the setup of a web server (GlassFish with GlassFish prelude, Apache Tomcat or both). Create a Web Application.

Download Presentation

Java Servlets example using NetBeans 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Servlets exampleusing NetBeans 6

  2. Pre-requirements: • Install Java JDK 1.6 • Install NetBeans IDE 6 (we will use version NetBeans IDE 6.7.1 update 16) • Remember to choose the setup of a web server (GlassFish with GlassFish prelude, Apache Tomcat or both)

  3. Create a Web Application • File -> New Project -> Java Web -> Web Application • Click Next, choose a name and a location for the project. We will call it ITShop • Click Next, Choose the Server that you want to use (GlassFish or Apache Tomcat) • Click Finish

  4. Build the home page • An ‘index.jsp’ page is created automatically. Write whatever html code you wish in it. You can also use the tools from the palette on the left. • We will write some hyperlink that will call the servlet and pass a value to its doGet method. • We also will put a form in that page that includes a text input, a submit button and a reset button.

  5. Create the servlet • Right click the project -> New -> Servlet... • Choose a name for the class (we will call it ‘PageCreatorServlet’). Click Next, choose a name for the servlet, (we will use the same name). Note that the check box of ‘Add information to deployment descriptor (web.xml)’ is checked. • Click Finish

  6. Edit the servlet • The ‘PageCreatorServlet’ will be created automatically, including its doGet and doPost methods. It also includes a ‘processRequest’ method that will be called from the doGet and doPost methods. • We can write our implementation in the doGet and doPost methods. But instead, here we will write in the processRequest method.

  7. Note: • You can run the servlet alone for testing purposes instead of runing the entire project. • Right click the servlet -> Run File. You can also add some parameters to the servlet execution URI (for example: /PageCreatorServlet?DATA=“SW”). • You can also change this execustion URI. To do so, right click the servlet -> Tools -> Set Servlet Execution URI • Run the project and test it.

More Related