NetBeans - Take 2 and Call Me in the Morning
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
- Create a new Web Application named HelloWorld (File > New Project > Web > Web Application).
- Change the text in index.jsp from "JSP Page" to "Hello World!".
- Press F6.
Frustration #2 - Closing and Opening a Project
- Choose File > Close "HelloWorld"
- 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.
- 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.
- Add the JSTL library to the project (Properties > Libraries > Add Library)
- Uncomment the <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> line in index.jsp
- Add the line <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
- Add the following between the <body> tags:
<h1>Customer List</h1>
<sql:setDataSource
var="customerDS"
driver="com.pointbase.jdbc.jdbcUniversalDriver"
url="jdbc:pointbase:server://localhost:9092/sample"
user="pbpublic"
password="pbpublic"
/>
<sql:query var="customerQuery" dataSource="${customerDS}">
SELECT * FROM CUSTOMER_TBL
</sql:query>
<TABLE border=1>
<TR>
<TD>Customer Num</TD>
<TD>Customer Name</TD>
<TD>Customer City</TD>
<TD>Customer Phone</TD>
</TR>
<c:forEach var="row" items="${customerQuery.rows}">
<TR>
<TD><c:out value='${row.CUSTOMER_NUM}'/></TD>
<TD><c:out value='${row.NAME}'/></TD>
<TD><c:out value='${row.CITY}'/></TD>
<TD><c:out value='${row.PHONE}'/></TD>
</TR>
</c:forEach>
</TABLE>
- Press Ctrl+Shift+F to reformat the code.
- 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)
- Press F6.
Headache cured.
- Login or register to post comments
- Printer-friendly version
- bleonard's blog
- 898 reads






