How to code and display a webpage using NetBeans in Java?
Let it go! Launch NetBeans. I use NetBeans 6.7.1 with Java EE installed, and I have GlassFish installed and bundled, so I don’t have to worry about that. Your setting may vary in detail.
Make File-> New Project and select "Java Web" from the categories. Select "Web Application" and click "Next." Enter the name of the project and adjust the location if you like it. Click Next. The next page should have a server selection dropdown; as outlined above, I have "GlassFIsh v2.1." This is great - as long as NetBeans can interact with any Java application server, this crash course will work fine.
Write down the "context path" - this will be based on the name of the project and basically forms the base of the URL where your application will be located. Click Next. Ignore the next page, for now, that talks about the various frameworks and click Finish.
Grinding, outflow. Ultimately, you should see that your web project is created. This is a very simple application that contains one JSP file and will open in the main editor. It has a bunch of HTML and some JSP syntax.
Take a look at the structure of the project. You have a Web Pages folder that contains the WEB-INF directory and the index.jsp file. This is the same file you are looking at. WEB-INF is the standard directory that contains the metadata used to deploy your application, as well as compiled classes that support it.
The only thing you need to do now to achieve your original goal is to click the Run button or right-click on the project and select Run from the menu. NetBeans will compile and then launch your application server and deploy the application to it. Finally, your web browser should open a new tab with the classic "Hello, world" page.
At the moment, what do you really have? You have an empty web project with one JSP file. You can customize it, but it may not be very interesting. What you are actually looking at is a basic framework in which you can apply your JSP and servlet training as soon as you deal with them.
How to continue the transfer of knowledge? I recommend a decent book or two. The one I used started with “Getting Started with JSP, JSF, and Tomcat Web Development: From Beginner to Professional” (Zambon, Guilio, Apress, ISBN 1-59059-904-7), which has a decent beginner's guide on how JSPs and servlets work together and a handy reference guide for the first.
As soon as possible, you will want to switch from raw servlets and JSPs to combining them in a slightly more flexible way, using one of the frameworks that I skipped earlier. I am not going to tell you what to learn; there are some pretty decent ones. Try Spring MVC or Struts. Once again, I suggest getting a decent book.