Skip to main content

NetBeans - Take 2 and Call Me in the Morning

Posted by bleonard on September 29, 2005 at 6:36 PM PDT

I came across this post from a frustrated developer today, and couldn't help but wonder - are we keeping NetBeans a secret? Poor Dan is just trying to create a simple JSP. For some reason, I couldn't see the code referenced in his post, but I think I got the gist of what he's trying to do. Let's tackle them one frustration at a time:

Frustration #1 - Create a Hello World Web Project

  1. Create a new Web Application named HelloWorld (File > New Project > Web > Web Application).
  2. Change the text in index.jsp from "JSP Page" to "Hello World!".
  3. Press F6.

Frustration #2 - Closing and Opening a Project

  1. Choose File > Close "HelloWorld"
  2. Choose File > Open Recent Project > HelloWorld

Frustration #3 - Working with JSTL

Here's where I couldn't see Dan's code. However, it looks like he's just trying to display some results from a table. For the purposes of this example, I'm just going to use the Pointbase database and sample data that comes with the J2EE 1.4 SDK. If you already have a different database set up, just change the settings to match your configuration.

  1. Add the Pointbase JDBC driver to the project (Properties > Libraries > Add JAR/Folder). It's in pbembedded.jar, which you'll find in the J2EE SDK's pointbase/lib directory. For me it's at C:\Sun\Appserver\pointbase\lib\pbembedded.jar.
  2. Add the JSTL library to the project (Properties > Libraries > Add Library)
  3. Uncomment the <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> line in index.jsp
  4. Add the line <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  5. Add the following between the <body> tags:
&lt;h1&gt;Customer List&lt;/h1&gt;
  
&lt;sql:setDataSource
var=&quot;customerDS&quot;
driver=&quot;com.pointbase.jdbc.jdbcUniversalDriver&quot;
url=&quot;jdbc:pointbase:server://localhost:9092/sample&quot;
user=&quot;pbpublic&quot;
password=&quot;pbpublic&quot;
/&gt;

&lt;sql:query var=&quot;customerQuery&quot; dataSource=&quot;${customerDS}&quot;&gt;
SELECT * FROM CUSTOMER_TBL
&lt;/sql:query&gt;

&lt;TABLE border=1&gt;
     &lt;TR&gt;
         &lt;TD&gt;Customer Num&lt;/TD&gt;
         &lt;TD&gt;Customer Name&lt;/TD&gt;
         &lt;TD&gt;Customer City&lt;/TD&gt;
         &lt;TD&gt;Customer Phone&lt;/TD&gt;
     &lt;/TR&gt;
     &lt;c:forEach var=&quot;row&quot; items=&quot;${customerQuery.rows}&quot;&gt;
         &lt;TR&gt;
             &lt;TD&gt;&lt;c:out value='${row.CUSTOMER_NUM}'/&gt;&lt;/TD&gt;
             &lt;TD&gt;&lt;c:out value='${row.NAME}'/&gt;&lt;/TD&gt;
             &lt;TD&gt;&lt;c:out value='${row.CITY}'/&gt;&lt;/TD&gt;
             &lt;TD&gt;&lt;c:out value='${row.PHONE}'/&gt;&lt;/TD&gt;
         &lt;/TR&gt;
     &lt;/c:forEach&gt;
&lt;/TABLE&gt;   
   
  1. Press Ctrl+Shift+F to reformat the code.
  2. Start Pointbase (Tools > Pointbase Database > Start Local Pointbase Database). Note, you need to have the J2EE 1.4 SDK added as a server to see this option (Tools > Server Manager > Add Server)
  3. Press F6.

result.png




Headache cured.

Related Topics >>