02. Servlet 3.0

Java Servlet 3.0 (JSR 315), which is part of Java EE 6, is a major revision of the Java Servlet technology, a widely accepted technology for building dynamic content for web-based applications, and includes changes to enable easy pluggability of popular open-source frameworks or libraries, ease of development leveraging annotation and making web.xml optional, support for async processing, which enables writing Comet applications in portable fashion, security enhancements, and other minor updates to the existing APIs.

In this lab, you are going exercise all the newly introduced features of Servlet 3.0.

Expected duration: 210 minutes (excluding homework)




Software Needed


Before you begin, you need to install JDK 6 and NetBeans IDE 6.8.  You also need to download and unzip the hands-on lab zip file below.
  • 4532_javaee6_servlet3.0.zip (download)
    • It contains this document and the lab contents
    • Download it and unzip in a directory of your choice

OS platforms you can use

  • Windows
  • Solaris x86, Solaris Sparc
  • Linux
  • Mac OS X

Lab Exercises


For the sake of the simplicity of the lab, most exercises are provided in the form of "ready-to-open-and-run" NetBeans projects.  (Many of them are borrowed from "glassfish-samples" and "Java EE 6 tutorial".)  Please feel free to create them from scratch if you want to. 

It is strongly encouraged, leveraging what is provided in this lab, you do your own experimentation meaning creating/adding your own code as much as you can. 

If you have written some code that might help everyone else, please feel free to share them on this codecamp email alias or directly send them to the instructors.  Your name will be recognized in this lab if your sample code is chosen to be included.  For the tasks that need to be done, please see the "Things to be done" section above.)


Exercise 1: Annotation

더보기



Exercise 2: Dynamic registration

더보기


 

Exercise 3: Pluggability of 3rd-party frameworks/libraries

더보기



 

Exercise 4: Resources in bundled jar

더보기


 

 

Exercise 5: Asynch. Servlet

더보기


 

 

Exercise 6: File upload support

더보기


 




Exercise 7: Build and run "sessioncookieconfig-war" sample application

더보기





Exercise 8: Security

더보기


Mandatory Homework Exercise (for people who are taking "Java EE 6 Codecamp")


1. The homework is to modify helloservlet project as following.  The helloservlet project is provided under <LAB_UNZIPPED_DIRECTORY>/javaee6_servlet3.0/samples directory. (You might want to create a new project by copying helloservlet project.  You can name the newly copied project in any way you want.  Here it is referred to as myhelloservlet.)
  • Goal: exercising annotations
    • Remove web.xml.
    • Use @WebServlet annotation for the GreetingServlet.
    • Use dynamic registration for the ResponseServlet.
  • Goal: exercising 3rd party library/framework pluggability
    • Create a library called mywebfragment1 with its own web-fragment.xml.
    • Define a filter in which "myfiltermessage" attribute in the request scope is appended with a value "mymessage1".  The filter configuration should be specified in the web-fragment.xml.
    • Create another library called mywebfragment2 without web-fragment.xml.  The filter configuration should be configured with @WebFilter annotation.
2. Send the following files to javaee6-homeworks@sun.com with Subject as homework_javaee6_servlet3.0.
  • Zip file of the the myhelloservlet NetBeans project.  (Someone else should be able to open and run it as a NetBeans project.)  You can use your favorite zip utility or you can use "jar" utility that comes with JDK as following.
    • cd <parent directory that contains myhelloservlet directory> (assuming you named your project as myhelloservlet)
    • jar cvf myhelloservlet.zip myhelloservlet (myhelloservlet should contain nbproject directory)
Or you can install Project Packager NetBeans plug-in (from http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3742).  You can then export your project as a zip file - the build and dist directories are removed automatically to make the smaller zip file. If you set up SMTP, you can even e-mail your zipped project to someone.
  • Captured output screen  - name it as homework_javaee6_servlet3.0.gif or homework_javaee6_servlet3.0.jpg (or homework_javaee6_servlet3.0.<whatever graphics format>)
    • Any screen capture that shows that your program is working is good enough. 

                                                                                                                    return to the top

Optional Homework Exercise (for people who are taking "Java EE 6 Codecamp")


You don't need to submit optional homework exercise unless you want to.

1. The homework is to modify async-request-war project as following.   (You might want to create a new project by copying async-request-war project.  You can name the newly copied project in any way you want.  Here it is referred to as my-async-request-war.)
  • Add a "Quit chatting" button, when pressed, to close a chatting session.
  • Add a "Restart chatting" button, when pressed, to restart a chatting session

2. Send the following files to javaee6-homeworks@sun.com with Subject as homework_javaee6_servlet3.0-optional.
  • Zip file of the the my-async-request-war NetBeans project.  (Someone else should be able to open and run it as a NetBeans project.)  You can use your favorite zip utility or you can use "jar" utility that comes with JDK as following.
    • cd <parent directory that contains my-async-request-war directory> (assuming you named your project as my-async-request-war)
    • jar cvf my-async-request-war.zip my-async-request-war (my-async-request-war should contain nbproject directory)
저작자 표시

Trackback 0 Comment 0