The Java Side of Things
As mentioned before, to expose the functionality of the components running on the server we'll use a Web Service. In the next step I'll explain how to setup a Web Application project in NetBeans 6.1. Those of you who are familiar with this aspect of Java EE can probably skip the next section.
Creating The Web Service
In this section I shall explain how to set up a Web Application project in NetBeans and add a Web Service to it. To create a new Web Application project click: File->New Project ... a window will appear (screen shot below), at this stage make sure you have selected Web in Categories and Web Application in Projects.
With the correct options selected, click Next. On the next screen, provide a name for the project. In my case, it is JPedal_Server. Apart from that there is no need to change anything else in this section. Click Next. On the new screen make sure you have Tomcat 6.0.16 selected as Server and Java EE 5 as your Java EE Version just like on the screen shot below.
With the correct selections made, click Finish. There is one more screen we could have gone through but it refers to frameworks available to our project, which we won't be making any use of. After the Finish button has been clicked you will notice that the main window in the IDE now displays the content of the index.jsp file. Next step is to add a Web service to our application. To do this you need to right-click the main project node, select New and from the following menu select Web Service.
Once you click the Web Service icon you will be presented with another dialogue window. Here, just provide the Web Service name, in my case PDFImage, and a package, say org.maz. Next, click Finish. A new tab will open in the main window where you will see your Web Service in a design view.
Before we start adding actual code to our service we need to do one more thing. As I mentioned before, we're going to let the Java PDF library deal with all the hardcore PDF parsing and rendering. To be able to do that we need to add the JPedal jar to the CLASSPATH of the project. In NetBeans this is done by right-clicking the main project node and selecting Properties form the menu. After that, we are greeted with another dialogue panel, there we should select Libraries from the Categories list and then click the 'Add JAR/Folder' button. This will allow us to find and select the needed jar.
When done, click OK.