Today is Wednesday, 11th January 2017

Archive for October, 2015


JSP Tutorial #1 – Java Server Pages Tutorial – Introduction

In this video, I will give you an introduction to the JSP tutorial series.

Please SUBSCRIBE to my YouTube channel.

 


 

# Video
1 Introduction
2 JSP Overview
3 Setting up your Development Environment - Overview
4 Installing Tomcat
5 Installing Eclipse
6 Connecting Eclipse to Tomcat
7 JSP Hello World
8 JSP Expressions
9 JSP Scriptlets
10 JSP Declarations
11 Importing Java Classes
12 JSP Built-In Objects
13 Including Files

Do You Need More Details?

  • How to read form data with JSP?
  • How to use cookies and sessions?
  • Develop MVC application with JSP and Servlets?
I have a premium course that shows you how to complete all of these tasks.

Read more about the premium course at http://www.luv2code.com/jsp

Follow luv2code with the links below:

– Website: http://www.luv2code.com
– YouTube: http://goo.gl/EV6Kwv
– Twitter: http://goo.gl/ALMzLG
– Facebook: http://goo.gl/8pDRdA

JSP Tutorial Transcript:

Hey, this is Chad “Shod” Darby, with www.luv2code.com.

Welcome to my tutorial on JSP. In this tutorial series we’re going to cover a lot of good topics. We’re going to start off with a tutorial intro which is, of course, this video, then we’ll get an overview of JSP, next you’ll learn how to set up your development environment and then we’ll learn about installing Tomcat, installing Eclipse, and also connecting Eclipse and Tomcat together. That will take care of all the basic housekeeping that we’ll need to do for setting up our development environment.

Next we’ll move forward and we’ll start coding so we’ll do our JSP Hello World program, then we’ll learn about some different aspects of JSP. We’ll discuss JSP expressions, scriplets and also JSP declarations. Then we’ll look at some of the JSP built-in objects. We’ll learn about including files and finally we’ll learn how to import Java classes.

This is a good start to get us going with JSP. Granted, there’s a whole lot of more topics out there on JSP, this is enough to get us a quick start with JSP so we can start with JSP development.

All right, we have a lot of good things in store. Stay tuned for all the follow on videos.

Share


JDBC BLOB: Handling large file sizes

JDBC has support for storing binary files in the database using the BLOB datatype. I covered this in a previous blog post: Reading and Writing BLOBs with MySQL.

However, you may run into errors if you need to store large files. In particular, you may encounter the following error messages:

By default, the BLOB datatype can only handle files up to 64KB.

MySQL has multiple datatypes for handling binary data:

Storing Larger Files

If you need to store larger files, then follow these steps:

1. Change the databtype of your BLOB column to LONGBLOB

2. Edit the MySQL configuration file

In this file, add the line:

See the image below

MySQL Config file

MySQL Config file

 

3. Save the file and restart your MySQL server

4. Test your application again. You will now be able to store large files.

 

Enjoy 🙂

Share


JSF: Setting itemLabel with selectItems

JSF provides UI components for drop-down lists. Drop-down lists are called selectOneMenu in JSF.

When you use the components, you may have the requirement to use different values for the itemLabel and itemValue. You can accomplish this by making use of a Map collection (java.util.Map). The Map collection is a collection of key-value pairs.

In JSF, you provide a reference to a Map and then JSF will build the list. It will use the Map key for the itemLabel and the Map value for the itemValue.

When the user selects an item, then the selected item’s value will be set on the bean.

Ok, enough talking, let’s look at an example.

In this example, I will present the user with a JSF form. The form will read the user’s first name, last name and country.

form-1

JSF Bean Code

The country drop down list is populated with a Map from the bean. The bean will define a Map collection that uses the Map key for the itemLabel and the Map value for the itemValue. Here’s the code snippet

JSF Page

Now the JSF page can make use of this bean to get the itemLabel and itemValues. Remember JSF will use the map key as the itemLabel and the map value as the itemValue

Here’s the snippet of code for the JSF page.

So when the form is displayed, the user will set the map keys in for the item label. For example, the user will see the full name of the country as shown below:

form-2

Then once they submit the form, JSF will store the value of the selected item into the bean.

Here’s a snippet of code from the response form that shows the user’s selected value:

So if the user selects “Germany”, then JSF will store the value of “DEU” for the bean property studentTwo.country.

final

Summary

Well, that covers how you can provide different itemLabels and itemValues for a drop-down list.

DOWNLOAD SOURCE CODE

 

Do You Need More Details?

  • Do you need to connect to a database?
  • Display SQL results in a HTML table?
  • Perform SQL insert, updates and deletes?
I have a premium course that shows you how to complete all of these tasks.
  • Database Integration with JDBC
  • Displaying Data in Lists and Tables
  • Validating HTML Forms
  • Implementing Business Logic with Managed Beans
  • Deploying applications with WAR Files
Read more about the premium course at http://www.luv2code.com/jsf-for-beginners

Follow luv2code with the links below:

– Website: http://www.luv2code.com
– YouTube: http://goo.gl/EV6Kwv
– Twitter: http://goo.gl/ALMzLG
– Facebook: http://goo.gl/8pDRdA

Share