11 the NetBeans E-Commerce Tutorial - Securing the Application - Free download as PDF File .pdf), Text File .txt) or read online for free. The NetBeans Ecommerce TutorialанаManaging Sessions that you build in this tutorial: NetBeans Ecommerce Tutorial Demo Application. Electronic Commerce, commonly known as e-commerce consists of the buying and To get a understanding of how to develop an E-Commerce application by using Mysql api. soundofheaven.info, accessed.
|Language:||English, Spanish, Indonesian|
|Genre:||Academic & Education|
|ePub File Size:||19.80 MB|
|PDF File Size:||20.54 MB|
|Distribution:||Free* [*Regsitration Required]|
Introduction to the NetBeans E-commerce Tutorial. About this Tutorial; What is an E-commerce Application? What is Java? What is the Java .. and Larry Brown . This book is freely available in PDF format from: soundofheaven.info The NetBeans E-commerce Tutorial (Complete Version) Hall and Larry Brown. This book is freely available in PDF format from: soundofheaven.info The NetBeans E-commerce Tutorial - Preparing the Page Views and. Controller Servlet. This tutorial unit demonstrates how to create project.
Noric Dilanchian. A small grocery store, the Affable Bean, collaborates with several local farms to supply a community with organic produce and foods. It is also referred to as business-to-customer , or B2C. A singleton session bean is instantiated once per application, and exists for the lifecycle of the application. Because customers can specify quantities for products in their shopping carts, we can also add a quantity column to the table. See the official EclipseLink documentation for an explanation of logging and a list of all logging values: Here are several noteworthy points:.
The images used in this tutorial are taken from version 5. There are slight differences in the graphical interface between versions, however the functionality remains consistent. Because version 5. If you are working in Workbench 5. In the default interface, begin by creating a new schema which will be used with the AffableBean application. Click the plus image:: A new panel opens in the bottom region of the interface, enabling you to specify settings for the new schema.
Schema used with the AffableBean application image:: Character Sets and Collations in General. You can drag-and-drop entity tables onto the canvas. A new EER Diagram opens displaying an empty canvas. Click the New Table image:: A new table displays on the canvas.
Double-click the table. The Table editor opens in the bottom region of the interface, allowing you to configure settings for the table. The terms 'table' and 'entity' are nearly synonymous in this tutorial unit. From the point of view of a database schema, you are creating tables. From a data modeling perspective, you are creating entities. Likewise, the columns that you later create for each table correspond to entity properties. In the Table editor, rename the table to one of the nouns you identified from the use-case above.
Optionally add a comment describing the purpose of the table. The InnoDB engine provides foreign key support, which is utilized in this tutorial. Under the Catalog tab in the left region of WorkBench right region for version 5.
The customer table now displays. More importantly, note that the new customer table is now included in the affablebean schema. Because the affablebean schema was selected when you created the new EER diagram, any changes you make to the diagram are automatically bound to the schema.
Repeat steps 2 - 4 above to add tables to the canvas for the remaining nouns you identified in the use-case above. Before naming your tables however, there is one important consideration which you should take into account. For a list of reserved words used by the MySQL server, refer to the official manual: Entity properties correspond to the columns defined in a database table. For example, consider the customer entity. In regard to the AffableBean application, what aspects of a customer would need to be persisted to the database?
These would likely be all of the information gathered in the checkout page 's customer details form, as well as some association to the processed order. When adding properties, you need to determine the most appropriate data type for each property. MySQL supports a number of data types in several categories: Refer to the official manual for a summary of data types within each category: Data Type Overview. In this tutorial, the data types have been chosen for you.
Choosing the appropriate data type plays a significant role in optimizing storage on your database server. For more information see:. Data Type Storage Requirements. Choosing the Right Type for a Column.
As with most of the initial design steps, determining the entity properties would call for careful consideration of the business problem that needs to be solved, and could require hours of analysis as well as numerous consultations with the client. In the Table editor click the Columns tab, then click inside the displayed table to edit the first column.
Enter the following details:. These columns should be self-explanatory, and represent data that would need to be captured for the Affable Bean business to process a customer order and send a shipment of groceries to the customer address.
Also click the Indexes row so that any table indexes are also visible. This includes primary and foreign keys, which becomes useful when you begin creating relationships between tables later in the exercise. When you finish, the customer entity looks as follows. Follow the steps outlined above to create columns for the remaining tables.
When you finish, your canvas will look similar to the following. So far, the entity-relationship diagram contains several entities, but lacks any relationships between them. The data model that we are creating must also indicate whether objects are aware of i.
If one object contains a reference to another object, this is known as a unidirectional relationship. Likewise, if both objects refer to each other, this is called a bidirectional relationship.
References correlate to foreign keys in the database schema. You will note that, as you begin linking tables together, foreign keys are added as new columns in the tables being linked. Two other pieces of information are also commonly relayed in an ERD: These are discussed below, as you begin adding relationships to entities on the canvas. In order to complete the ERD, you essentially need to create two one-to-many relationships, and one many-to-many relationship.
Details follow. Examine the four objects currently on the canvas while considering the business problem. You can deduce the following two one-to-many relationships:. Incorporate these two relationships into the ERD. You can download a copy of the MySQL Workbench project that contains the four entities required for the following steps: In the left margin, click the 1: This enables you to create a one-to-many relationship.
Click the product table, then click the category table. The first table you click will contain the foreign key reference to the second table.
Here, we want the product table to contain a reference to category. The entity-relationship diagram in this tutorial uses Crow's Foot notation. Double-click the relationship i. The Relationship editor opens in the bottom region of the interface.
In other words, "product x belongs to category y. A product object contains a reference to the category it belongs to, but the related category object does not contain any references to the products it contains.
Click the Foreign Key tab in the Relationship editor. You see the following display. Toggle the Mandatory checkbox for either side. A non-identifying relationship, such as this one, refers to the fact that the child object product can be identified independently of the parent category. An identifying relationship means that the child cannot be uniquely identified without the parent.
An example of this is demonstrated later, when you create a many-to-many relationship between the product and order tables. Click the 1: Click the order table first this table will contain the foreign key , then click the customer table.
A relationship is formed between the two tables. The relationship now reads, "customer order x is placed by customer y. You can click and drag tables on the canvas into whatever position makes the most sense for your model. In the image above, the order table has been moved to the left of customer.
Many-to-many relationships occur when both sides of a relationship can have numerous references to related objects. The data model would have to account for this by including a many-to-many relationship between product and category , since a category contains multiple products, and a product can belong to multiple categories. In order to implement a many-to-many relationship in a database, it is necessary to break the relationship down into two one-to-many relationships.
In doing so, a third table is created containing the primary keys of the two original tables. The product - category relationship described above might look as follows in the data model. Now, consider how the application will persist customer orders.
However, there currently is no indication of the products contained in the order, nor their quantities. Because customers can specify quantities for products in their shopping carts, we can also add a quantity column to the table.
In the left margin, click the n: This enables you to create a many-to-many relationship. Recall that an identifying relationship means that the child cannot be uniquely identified without the parent.
Identifying relationships are indicated on the Workbench canvas by a solid line linking two tables. Arrange the tables according to the following image.
The many-to-many relationship is highlighted below. Rename the foreign key indexes to correspond to the new table name. When you finish, the two entries should read:.
Double-click the lines between the two objects and delete the default captions in the Relationship editor. Enter the following details.
You have now completed the ERD entity-relationship diagram. This diagram represents the data model for the AffableBean application. As will later be demonstrated, the JPA entity classes that you create will be derived from the entities existing in the data model.
You can also create notes for your diagram using the New Text Object image:: The wizard that you use also enables you to immediately run the script on your database server. Make sure your MySQL database server is running. Steps describing how to setup and run the database are provided in Setting up the Development Environment: Communicating with the Database Server. Set the default storage engine used in Workbench to InnoDB. If you attempt to create items on the MySQL server that already exist, the server will flag an error.
Click Continue. Click the Show Filter button and note that all five tables in the affablebean schema are included. Optionally, click Save to File to save the script to a location on your computer. In examining the script, you may notice that the following variables are set at the top of the file:.
For an explanation of what these variables are, and their purpose in the script, see the official Workbench manual: Chapter Click Execute. In the final panel of the wizard, you receive confirmation that the wizard was able to connect to and execute the script successfully.
The affablebean schema is now created and exists on your MySQL server. In the next step, you connect to the schema, or database , from the IDE. See Think of a schema as a blueprint that defines the contents of the database, including tables, relationships, views, etc. A database implements the schema by containing data in a way that adheres to the structure of the schema.
This is similar to the object-oriented world of Java classes and objects. A class defines an object. When a program runs however, objects i. Make sure that you have followed the steps outlined in Setting up the Development Environment: Refresh the connection to the affablebean database. To do so, right-click the connection node and choose Refresh. Expand any of the table nodes. The IDE is now connected to a database that uses the schema you created for the AffableBean application.
From the IDE, you can now view any table data you create in the database, as well as directly modify, add and delete data. For more information, see Data Definition Language [Wikipedia]. After creating necessary project files, you begin organizing the front-end of the application. In this unit, you also create a web deployment descriptor web.
You can use the deployment descriptor to specify configuration information which is read by the server during deployment. Although the Servlet 3. Specifically, in this unit you add directives for the header and footer and specify which files they will be applied to. One of the goals of this tutorial unit is to create JSP pages that correspond to the views specified in the application design. Referring back to the page mockups and process flow diagram , you begin implementing page layouts according to the mockups by creating placeholders for all visual and functional components.
This unit provides a guide for implementing the layout of the welcome page. You can apply the outlined steps to create the other pages on your own, or download project snapshot 1 , which provides completed layouts for all pages.
You can click the New File image:: In the following sub-sections, create JSP pages and a stylesheet for the project. Begin working in the project by creating JSP pages that correspond to the views displayed in the process flow diagram.
The index. Repeat steps 1 - 4 above to create the remaining cart. When you finish, your Projects window will look as follows: If the Cascading Style Sheet item is not listed, choose Other. The purpose of this section is to design the page views so that they begin to mirror the provided page mockups. Browser compatibility note: This tutorial uses Firefox 3 and does not guarantee that page view markup is compatible with other modern browsers.
If a browser installed on your computer is not displayed, click the Edit button and register the browser manually. Preparing the display of your web pages is usually an iterative process which you would fine-tune with regular feedback from the customer.
The following steps are designed to introduce you to the facilities provided by the IDE, and demonstrate how to get started using the welcome page mockup as an example. You can create five tags altogether: New code is shown in bold. Open the affablebean. In order to horizontally center the four areas in the page, you can include margin: Then include float: The footer requires clear: Click the Run Project image:: Project files that contain changes are automatically saved, any Java code in the project compiles, the project is packaged and deployed to GlassFish, and your browser opens to display the current state of the welcome page.
Now, begin creating placeholders for page components within each of the four visible areas. Start with the header. Reviewing the welcome page mockup , the header should contain the following components:. New code shown in bold. Aside from typical syntax highlighting that lets you differentiate between tags, attributes, attribute values, and text, there are plenty of other features.
When typing tags and attributes in the editor, you can invoke code-completion and documentation support by pressing Ctrl-Space. The IDE presents a list of suggestions which you can choose from, as well as a documentation window that defines the selected item and provides code examples. The IDE detects errors in your code and provides you with warnings, error messages, and in some cases, suggestions.
Warning messages are displayed in yellow, while errors are shown in red. You can hover your pointer over a designated area to view the message in a tooltip. You can also take advantage of numerous keyboard shortcuts. In the stylesheet, create rules for the new IDs and classes. Add the following rules beneath the header rule.
For the logo rule, you apply margin-left and margin-top properties to position the component on the page. If there are properties in the above code that you are unfamiliar with, position your cursor on the given property and press Ctrl-Space to invoke a pop-up window that provides documentation support. To see how a property is affecting your page, you can comment it out, then refresh the page in the browser.
This means that every time you save a file, the file is automatically compiled i. Simply save your file s , then switch to the browser and refresh the page. By following the previous steps, you are probably able to see a pattern emerging. For each area on the page, you perform three steps. Create the structure in HTML. Create a set of styles to define the appearance. View the page to examine the results of your changes.
Create placeholders for components in the right column. According to the welcome page mockup , the right column contains four evenly-spaced boxes. Create the structure for the four boxes. Add style rules to affablebean. When working in stylesheets, there are two windows that can be particularly helpful.
The CSS Preview enables you to view style rules as they are rendered in a browser. When you place your cursor within a style rule in the editor, the CSS Preview automatically refreshes to display sample text according to the properties defined in the rule.
Using this interface, you can construct rules by choosing properties and values from a graphical interface. When you make a selection in the Style Builder, the style rule is automatically updated in the editor. Likewise, when you type changes into the editor, the selections in the Style Builder are instantly updated. Make changes to the affablebean. All placeholders for page components exist. Later in the tutorial, when you begin to apply dynamic logic to the page views, you can simply plug JSTL and EL expressions into these placeholders.
The task remains for you to implement the initial design for the other pages based on the mockups. To accomplish this, follow the pattern outlined above, namely:. Some tips and tricks are outlined below. Images of initial mockup implementations for the remaining pages are included here. The background colors for each page area only serve to help you position elements while developing the application. You can do this by adjusting the background rule for the main class:. If you familiarize yourself with keyboard shortcuts and buttons in the editor toolbar, you can increase your productivity.
Code completion: When you type in tags and attributes, suggestions for code completion automatically appear in a pop-up box. Pressing Enter completes the suggested tag. Toggle line numbers: Right-click in the left margin and choose Show Line Numbers. Find occurrences: All matches become highlighted in the editor. To toggle highlighting, press the Toggle Highlight Search image:: Create a bookmark: Press the Toggle Bookmark image:: Copy a code snippet up or down: Highlight opening and closing tags: Place your cursor on either the opening or closing tag, and both are highlighted in yellow.
Looking back at the page mockups that were created, you can see that the welcome page should look the same whenever it is requested, for whomever requests it. Sessions are discussed in Unit 8, Managing Sessions. Notice however that all other pages do need some form of user-specific information to display properly. Then move all JSP pages other than the welcome page into this new folder.
In the New Folder wizard, name the folder view and click Finish. Notice that a new folder node appears in the Projects window. Move the category. You can do this by clicking on cart. This selects the four files.
To demonstrate that these pages are no longer accessible from a browser, click the Run Project image:: When the application displays in your browser, enter the full path to any of these files in the address bar. For example, type in:. Looking at the page mockups , it is easy to see that all of the five views share identical content; at the top, they contain the company logo, a language toggle, and other widgets associated with shopping cart functionality.
Likewise, when you right-click a node in the Projects window and choose New, the list of file types is partially determined by your previous selections.
Create two JSP segments: Now, you can copy the header code from any of the JSP pages and paste it into the header. Likewise, you can copy the footer code from any of the JSP pages and paste it into the footer. When you finish this task, you can remove the header and footer code from all of the JSP pages. Copy the header code from any of the JSP pages and paste it into the header. Be sure to include placeholders for the shopping cart widget, language toggle, and 'proceed to checkout' button used along the top of page views.
After you paste code into header. Copy the footer code from any of the JSP pages and paste it into the footer. After you paste code into footer.
Remove the header and footer code from all five JSP pages index. The application still needs to know which pages the header and footer files will be applied to.
An alternative solution would be to create a web. Click Next. Note that the file is named web. The web. The interface is categorized by the areas that can be configured in a web application. These areas are displayed as tabs in the editor toolbar, and include topics such as Servlets, Filters, References, and Security. The XML tab displays the entire source code for the file.
This is demonstrated in the following steps. Leave Display Name blank. Both the Display Name and Description fields are optional. For URL Patterns, specify the paths to the five views. Separate the two paths with a comma. Switch back to the XML tab. Notice that the following code has been added to the deployment descriptor. You may need to add carriage returns to the code so that it displays on multiple lines. Switch to the Pages tab again, and in the Include Preludes and Include Codas fields, enter the paths to the header.
You can click the Browse button and navigate to the files in the provided dialog. Note that the following code has been added. Changes in bold. To view the definitions of the above tags, as well as all tags available to you in the web deployment descriptor, consult the Servlet Specification. Run the application again press F6; fn-F6 on Mac. You will see that the welcome page displays as it did previously , with header and footer content included.
The controller servlet handles incoming requests by initiating any actions needed to generate the model for the request, then forwarding the request to the appropriate view.
The IDE provides a Servlet wizard that enables you to define the servlet component in a web application either by including the WebServlet annotation in the generated class, or by adding the necessary directives to the deployment descriptor. In the Package field, type controller. The new package is automatically created when you complete the wizard. Step 3 of the wizard lets you configure the servlet.
Of primary importance are the URL patterns that you need to specify. The patterns identify the URLs that invoke the servlet. The URL patterns should correspond to the views and actions that a user can initiate. Looking at the welcome page mockup , a user should be able to select a category. Likewise, in the category page , users should be able to add an item to the shopping cart. Patterns are separated by commas. The servlet and URL patterns are included in the WebServlet annotation that appears above the class signature.
The application requires more URL patterns for other actions and views. You can type in the following patterns:. You can also reformat the annotation as follows:. Finally, include the loadOnStartup element so that the servlet is instantiated and initialized when the application is deployed. A value of 0 or greater will cause this to happen -1 is the default. As previously stated, the controller servlet handles incoming requests by initiating any actions needed to generate the model for the request, then forwarding the request to the appropriate view.
You may need to expand the code fold by clicking the plus icon image:: The IDE provides you with a basic template for any new file you create. The IDE provides a template for virtually any file type.
Expand the Web category, then select the Servlet template. Modify the template in the editor. The next time you create a new servlet e. Also, instantiate a RequestDispatcher to forward the requested pattern to the appropriate view.
Examine the code above. There are several points to note: The RequestDispatcher is obtained from the HttpServletRequest and applies the url to forward the request:. Applying TODO notes in your code is a useful way to keep track of tasks that you need to complete. You can control the keywords that display in the Tasks window.
Run the project press F6; fn-F6 on Mac and test to see whether the ControllerServlet is forwarding requests to the appropriate views.
Type in http: Entering http: In the next tutorial unit, you take measures to enable connectivity between the application and the database. This tutorial unit focuses on communication between the database and the application.
You set up a data source and connection pool on the GlassFish server, and proceed by creating a JSP page that tests the data source by performing a simple query on the database. This unit also addresses how the application retrieves and displays images necessary for web presentation, and how to set context parameters and retrieve their values from web pages.
AffableBean project. You can follow this tutorial unit without having completed previous units. To do so, perform the following three steps:. Set up your MySQL database server. Follow the steps outlined in: Click the Run SQL image:: The script runs on your MySQL server. Tables are generated for the affablebean database. Open the project snapshot in the IDE. Begin by adding sample data to the category and product tables. Note that the table is empty, as no data has yet been added.
The SQL statement is executed. To do so, you can use the SQL History window. Click the SQL History image:: Watch the screencast below to see how you can follow the above steps. Right-click the product table image:: Examine the above code and note the following points: The SQL engine will therefore provide the current date and time for this field when a record is created. For example, the following statement elicits the same result as the first line of the above code:.
Because you have already added four records to the category table, the product records you are inserting reference one of these four records. You can see 16 new records listed in the table. In the Services window, when you right-click a table image:: You can also use this GUI support to add, modify, and delete table data. Add new records: To add new records, click the Insert Record image:: An Insert Records dialog window displays, enabling you to enter new records.
When you click OK, the new data is committed to the database, and the GUI representation of the table is automatically updated.
Modify records: You can make edits to existing records by double-clicking directly in table cells and modifying field entries. Modified entries display as green text. When you are finished editing data, click the Commit Record image:: Similarly, click the Cancel Edits image:: Delete individual records: Click a row in the table, then click the Delete Selected Record image:: Delete all records: Deleting all records within a table is referred to as ' truncating ' the table.
Click the Truncate Table image:: If the displayed data needs to be resynchronized with the actual database, you can click the Refresh Records image:: Note that much of the above-described functionality can also be accessed from the right-click menu within the GUI editor. From this point onward, you establish connectivity between the MySQL database and the affablebean application through the GlassFish server which it is deployed to.
For example, you start by creating a connection pool on the GlassFish server. A connection pool contains a group of reusable connections for a particular database. Because creating each new physical connection is time-consuming, the server maintains a pool of available connections to increase performance. When an application requests a connection, it obtains one from the pool.
When an application closes a connection, the connection is returned to the pool. Connection pools use a JDBC driver to create physical database connections. A data source a. Applications get a database connection from a connection pool by looking up a data source using the Java Naming and Directory Interface JNDI and then requesting a connection.
The connection pool associated with the data source provides the connection for the application. In order to enable the application access to the affablebean database, you need to create a connection pool and a data source that uses the connection pool.
You can also create connection pools and data sources directly on the GlassFish server using the GlassFish Administration Console. However, creating these resources in this manner requires that you manually enter database connection details i. The benefit of using the NetBeans wizard is that it extracts any connection details directly from an existing database connection, thus eliminating potential connectivity problems. The setup instructions are provided for later tutorial units.
Click the New File image:: When you do so, three new steps are added to the wizard, enabling you to specify connection pool settings. JNDI Name: In Step 3, Additional Properties, you do not need to specify any additional configuration information for the data source. Also, ensure that the Extract from Existing Connection option is selected, and that the jdbc: Datasource Classname: Optional Connects to the affablebean database Also, note that the wizard extracts and displays properties from the existing connection.
The wizard generates a sun-resources. The sun-resources. When the project next gets deployed, the server will read in any configuration data contained in sun-resources. Note that once the connection pool and data source exist on the server, your project no longer requires the sun-resources. Here you see the XML configuration required to set up the connection pool and data source. Code below is formatted for readability. The GlassFish server reads configuration data from the sun-resources.
Right-click data source and connection pool nodes to view and make changes to their properties. You can associate a data source with any connection pool registered on the server. You can edit property values for connection pools, and unregister both data sources and connection pools from the server.
Then proceed by adding a reference in your project to the data source you created on the server. Ensure that the GlassFish server is already running. Note the small green arrow next to the GlassFish icon image:: If the server is not running, right-click the server node and choose Start.
Right-click the server node and choose View Admin Console. The GlassFish Administration Console opens in a browser. Log into the administration console. In the main window, the Edit Connection Pool interface displays for the selected connection pool.
Click the Ping button. In the Projects window, expand the Configuration Files folder and double-click web. Click the References tab located along the top of the editor.
Expand the Resource References heading, then click Add. The Add Resource Reference dialog opens. Optional Connects to database for AffableBean application image:: The new resource is added under the Resource References heading. Create a new JSP page to test the data source. Click finish.
In the new testDataSource. Press Return, then press Ctrl-Space to invoke code suggestions. Choose DB Report from the list of options. If line numbers do not display, right-click in the left margin of the editor and choose Show Line Numbers. Query Statement: The dialog adds the taglib directives for the JSTL core and sql libraries to the top of the file:. In the left column, select the GlassFish server you are deploying to.
The output indicates that the driver JAR file mysql-connector-java Examine testDataSource. You see an HTML table listing data contained in the category and product tables.
At this stage, we have set up a working data source and connection pool on the server, and demonstrated that the application can access data contained in the affablebean database. This section demonstrates how to configure context parameters for the application, and how to access parameter values from JSP pages. The owner of an application may want to be able to change certain settings without the need to make intrusive changes to source code.
Context parameters enable you application-wide access to parameter values, and provide a convenient way to change parameter values from a single location, should the need arise. By way of demonstration, you create context parameters for the image paths to category and product images used in the AffableBean project.
Begin by adding the provided image resources to the project, then perform the two steps outlined above. Download the website sample images , and unzip the file to a location on your computer. The unzipped file is an img folder that contains all of the image resources required for the AffableBean application.
Import the img folder into the AffableBean project. In the Projects window, expand the Configuration Files node and double-click web. Optional The relative path to product images image:: Optional The relative path to category images. The two context parameters are now listed: For example, open index. Run the project. In this final section, you combine these achievements to plug the product and category images into the application.
Before embarking upon an exercise involving JSTL, one implementation detail needs to first be clarified. Examine the files contained in the categories and products folders and note that the names of the provided image files match the names of the category and product entries found in the database.
This enables us to leverage the database data to dynamically call image files within the page. So for example, if the web page needs to access the image for the broccoli product entry, you can make this happen using the following statement.
Begin by integrating the category images into the index page, then work within the category page so that data pertaining to the selected category is dynamically handled. In the Projects window, double-click the index. If already opened, press Ctrl-Tab to select it in the editor. In the code-completion pop-up window that displays, choose DB Query. Also, note that the required reference to the sql taglib directive has been automatically inserted at the top of the page.
Changes displayed in bold. The SQL query creates a result set which is stored in the categories variable. You can then access the result set using EL syntax, e. Also, note that the required reference to the core taglib directive has been automatically inserted at the top of the page. More specifically, categories refers to an object that implements the javax. Result interface. When you finish, the complete index. Click any of the four images in the browser.
The category page displays. In your development environment, the URL is:. The sun-web. Also, note that a question mark? This forms the query string. As is demonstrated in the next section, you can apply pageContext. You can then use the category ID from the query string to determine which category details need to be included in the response.
Three aspects of the category page need to be handled dynamically. The left column must indicate which category is selected, the table heading must display the name of the selected category, and the table must list product details pertaining to the selected category. In order to implement these aspects using JSTL, you can follow a simple, 2-step pattern:. In the Projects window, double-click the category.
Make sure to add the JSTL core and sql taglib directives to the top of the page. In the browser, navigate to the category page and click the category buttons in the left column. Each time you click, the page refreshes highlighting the selected category. Your servlet container i. You can view the generated servlet for a JSP page by right-clicking the page node in the Projects window and choosing View Servlet.
Of course, you first need to run the project so that the servlet is generated. Taking the index.
The servlet exists on the server at: Taking your current implementation of category. To set a breakpoint, click in the left margin of the line. A breakpoint image:: Click the bakery category in the index page. Return to the IDE, and note that the debugger is suspended on the line containing the breakpoint. When suspended, the margin shows a green arrow on the breakpoint image:: Press the Finish Debugger Session image:: Add the following SQL query to the top of the file, underneath the query you just implemented.
New query is shown in bold. Displayed in bold. Since the result from the selectedCategory query contains only one item i. Return to the browser and refresh the category page. The name of the selected category now displays above the product table. As demonstrated in this and the previous step, you do not need to explicitly recompile, deploy, and run the project with each change to your code base.
To verify that the feature is activated, right-click your project node in the Projects window and choose Properties. Add the following SQL query to the top of the file, underneath the previous queries you implemented. Changes are displayed in bold. Note that in the above snippet an EL expression is used to determine the background color for table rows:. Therefore, iter.
Continuing with the expression, iter. Finally, an EL conditional operator? Product details now display within the table for the selected category. You have now completed this tutorial unit. In it, you explored how to connect your application to the database by setting up a connection pool and data source on the server, then referenced the data source from the application.
You also created several context parameters, and learned how to access them from JSP pages. The solution project contains enhancements to the HTML markup and stylesheet in order to properly display all provided images. It also provides welcome page text, and a basic implementation for the page footer. If you are having problems, see the troubleshooting tips below. If you continue to have difficulty, or would like to provide constructive feedback, use the Send us Your Feedback link. Try to deploy the project, then access the file by typing its URL in the browser.
For example, if you are trying to view testDataSource. In the Projects window, right-click the Libraries node and choose Add Library.
Select JSTL 1. For more information, see: This can occur when the MySQL driver has not been added to the domain lib folder. Java EE currently dominates the market, especially in the financial sector. For a recent, informal comparison of Java EE to. There are many abbreviations and acronyms to parse. Unraveling Java Terminology.
JSRs are run by an Expert Group , which typically comprises representatives of companies that are stakeholders in the industry. The JCP enables Java technology to grow and adapt according to the needs and trends of the community.
JSR In this tutorial, you utilize these implementations to develop the sample e-commerce application. For example, the GlassFish v3 application server, which is included in the standard Java download bundle for NetBeans 6. Firstly, the term IDE stands for integrated development environment.
Consider what would be necessary if you wanted to create a Java-based web application manually. After installing the Java Development Kit JDK , you would need to set up your development environment by performing the following steps. Create a development directory where you plan to create and work on the web application s. Furthermore, you are responsible for setting up the application directory structure so that it can be understood by the server.
For example, see Java BluePrints: Strategy for Web Applications for a recommended structure. Establish a deployment method, i. For educative purposes, it is worthwhile to create and run a Java web project manually so that you are aware the necessary steps involved.
An IDE streamlines the process outlined above. Furthermore, the IDE provides provides built-in API documentation which you can either call up as you code in the editor, or maintain open in an external window. An IDE also typically handles project compilation and deployment in a way that is transparent to you as a developer. For example, the web project that you create in NetBeans includes an Ant build script that is used to compile, clean, package and deploy the project.
This means that you can run your project from the IDE, and it will automatically be compiled and deployed, then open in your default browser. In other words, whenever you save changes to your project, the deployed version on your server is automatically updated.
You can simply switch to the browser and refresh the page to view changes. IDEs also provide templates for various file types, and often enable you to add them to your project by suggesting common locations and including default configuration information where necessary. Aside from the "basic support" described above, IDEs typically provide interfaces to external tools and services e.
Finally, IDEs usually provide enhanced editor support. The editor is where you likely spend most of your time working, and IDE editors typically include syntax highlighting, refactoring capabilites, keyboard shortcuts, code completion, hints and error messages, all aiming to help you work more efficiently and intelligently.
People are saying great things about NetBeans. Here are several noteworthy points:. Works Out of the Box: Simply download, install, and run the IDE. With its small download size, installation is a breeze. All IDE tools and features are fully integrated - no need to hunt for plug-ins - and they work together when you launch the IDE.
Free and Open Source: When you use the NetBeans IDE, you join a vibrant, open source community with thousands of users ready to help and contribute. Profiling and Debugging Tools: With NetBeans IDE profiler , you get real time insight into memory usage and potential performance bottlenecks.
Furthermore, you can instrument specific parts of code to avoid performance degradation during profiling. The HeapWalker tool helps you evaluate Java heap contents and find memory leaks.
Customizable Projects: Through the NetBeans IDE build process, which relies on industry standards such as Apache Ant , make , Maven , and rake - rather than a proprietary build process - you can easily customize projects and add functionality. You can build, run, and deploy projects to servers outside of the IDE. Collaboration Tools: Extensive Documentation: Core Technologies, 2nd Edition. Advanced Technologies, 2nd Edition.
This book is freely available in PDF format from: Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
Apache NetBeans. Apache NetBeans incubating. Just released! What is Java? What is the Java Community Process? Why use an IDE? Why use NetBeans? See Also. These include: About this Tutorial Who this Tutorial is for The content of this tutorial caters to four demographics: Java developers interested in expanding their skill set to include Java EE technologies Newcomers to the NetBeans IDE wanting to try out its development environment Web developers wanting to see how Java compares to other web-based technologies Students wanting to understand the nuts and bolts a simple e-commerce application, and how its development could apply to a real-world use-case.
What this Tutorial Covers The application that you develop in this tutorial involves numerous concepts, technologies, and tooling components: What is an E-commerce Application?
Other well-known forms include: Software that accommodates a B2C scenario generally consists of two components: Java as a Programming Language The Java language was conceptualized by James Gosling , who began work on the project in The language was created with the following 5 design principles  in mind: Java as a Platform The Java Platform signifies a software-based platform that is comprised of two parts: Web application technologies Enterprise application technologies.
The JSRs of technologies used and referred to in this tutorial include the following: