NetBeans v6.9.1 Notes

hundredhonkSoftware and s/w Development

Aug 15, 2012 (4 years and 10 months ago)

244 views

These instructions lead you through step-by-step in setting up NetBeans projects so that they:
will run the file named index.html (rather than index.jsp) when you select Run -> Run Main Project from the NetBeans main
menu (or press the F6 key or click the green right arrow button)
automatically create an XHTML file that will validate against the
W3C Markup Validation Service when you request NetBeans to make
an XHTML file
Step 1: Make Tomcat Recognize index.html as a Startup File
Edit the web.xml file
expand the Web Pages treea.
expand the WEB-INF treeb.
double-click web.xml to bring up the file in the editor windowc.
click Pages to get to the screen shown below

d.
1.
Add index.html and index.html to the Welcome Files list as shown above, separated by commas

2.
Click the Save all files icon to save your changes3.
if this icon is disabled (grayed out), it is probably because the Welcome Files text box still has focus
in that case, press the TAB key and the Save all files icon should become active

N
etBeans v6.9.1 Notes 1
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M
Close the

web.xml editor4.
Step 2: Modify the HTML Template for Use in This Course
Select Tools -> Templates to open the Template Manager

1.
Copy the HTML template (do not copy the XHTML template, as doing so makes the process more complex)2.
scroll down and expand the Web tree
select the HTML entry and click the Duplicate button

This will create a new entry in the list named Html_1.xhtml
highlight this entry and click the Rename button
rename this entry to something more meaningful – I named mine XHTML-JMH
3.
N
etBeans v6.9.1 Notes 2
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M

Open the renamed file in the editor
IMPORTANT NOTE: When you open the duplicated file, you will see the following message. Just click the Yes
button to continue. This error will go away when you edit the file in the next step.
4.
N
etBeans v6.9.1 Notes 3
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M
Edit the text so that it looks as shown below, obviously replacing the information specific to me with your own

5.
here is the text for cutting and pasting
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Document : ${name}.html
Created on : ${date} at ${time}
Author : ${user}, replace with your e-mail address
91.461 GUI Programming I, Spring 2010
UMass Lowell Computer Science
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<meta name="Author" content="replace with your name, your e-mail address" />
<title>desired page title</title>
</head>
<body>
TODO write content
</body>
</html>
Save the template and close the editing window6.
Step 3: Create an XHTML File Using Your Template
Highlight the Web Pages entry in your projects window

1.
Ask NetBeans to create a new file by selecting File -> New File... from the NetBeans main menu or by typing Ctrl+N

2.
In the Categories pane, select Web, and in the File Types pane, select your own XHTML template (mine is called XHTML-JMH)3.
N
etBeans v6.9.1 Notes 4
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M

Click the Next> button

4.
Name your file (change the default, which is newHtml_1) and click the Finish button5.
if you name your file index, so that NetBeans creates index.html, it can be the startup file for your web application
to make your index.html file the startup file rather than the original index.jsp file, simply delete the index.jsp file
N
etBeans v6.9.1 Notes
5
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M
Step 4: Test Your XHTML File
If you named your file index.html and deleted the original index.jsp file, select Run -> Run Main Project from the NetBeans main
menu (or press the F6 key or click the green right arrow button) to display it in your default browser

1.
If you named your file something else, right-click it and select Run File (or select the file and press Shift-F6) to display it in your
default browser
2.
N
etBeans v6.9.1 Notes 6
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M
Additional Notes
If you use the default NetBeans XHTML template, The created file has an extension of .xhtml1.
this will work fine in Firefox, but not in Internet Explorer
to get the file to load in Internet Explorer, you must change the extension to the standard .html
however, you cannot change the extension by editing the file name in the Projects window file tree
when you click the file name and press the F2 key as you do to change file names in Windows explorer, the extension
disappears
this is intentional, because NetBeans has to know what type of file it’s deal with, which isn't always indicated by the
extension
to change the extension, right-click the file name in the Projects window file tree and select Properties
N
etBeans v6.9.1 Notes 7
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M

in the Properties dialog box, click the value in he Extension field to select it and retype it and then click the Close button
N
etBeans v6.9.1 Notes 8
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M
N
etBeans v6.9.1 Notes 9
http://teaching.cs.uml.edu/~heines/91.461/91.461-2010-11f/461-lecs/Net...9/4/2010 10:18 P
M