Creating Servlet Filters with Rational Application Developer


 
   

You can find the original, high resolution video tutorial on creating Java ServletFilters right here: http://jpa.thebookonhibernate.... a Custom Servlet FilterThis free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create a Servlet Filter. The web.xml file is then edited to apply the filter to the CountrySnooperServlet, to ensure that only true, patriotic Americans actually get to see the output of the CountrySnooperServlet. We also add in a little TimeStamping or Time Logging functionality, but that's neither here nor there.If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java! package com.examscam.web.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;public class AmericanFilter implements Filter { public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String language = request.getLocale().getDisplayLanguage(); if (language!="Spanish") { response.getWriter().print("Only people speaking American can view this Servlet."); } else{ chain.doFilter(request, response); } System.out.println("Time after the servlet is run: " + System.currentTimeMillis()); } public void destroy() { // TODO Auto-generated method stub }}Google Enter your search terms Submit search formDownload the Completed Solution: 08ServletFilters.ear.Scroll to the bottom of the page for pertinent code snippets.Creating a Custom Servlet FilterThis free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create a Servlet Filter. The web.xml file is then edited to apply the filter to the CountrySnooperServlet, to ensure that only true, patriotic Americans actually get to see the output of the CountrySnooperServlet. We also add in a little TimeStamping or Time Logging functionality, but that's neither here nor there.If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java!package com.examscam.web.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;public class AmericanFilter implements Filter { public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String language = request.getLocale().getDisplayLanguage(); if (language!="Spanish") { response.getWriter().print("Only people speaking American can view this Servlet."); } else{ chain.doFilter(request, response); } System.out.println("Time after the servlet is run: " + System.currentTimeMillis()); } public void destroy() { // TODO Auto-generated method stub }}package com.examscam.servlet;import java.io.IOException;import javax.servlet.Servlet;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServlet equest;import javax.servlet.http.HttpServlet esponse;public class CountrySnooper extends HttpServlet implements Servlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String country = request.getLocale().getCountry();if (country.equals("CA")){respons .getWriter().print("Hey, lets go for a Tim Hortons coffee!");}else {response.getWriter().print("We love people who speak " + request.getLocale().getDisplay anguage());}}} You can download the Java source code here: http://jpa.thebookonhibernate.... check out my SCJA Java Certification Mock Exam website: http://www.scja.com/associate/... And for Hibernate and JPA tutorials, check out: http://www.thebookonhibernate.... IRAD SCWCD

Canal: Education
Añadido: November 30, 1999 at 12:00 am
Autor: javaprogrammingcbts

Duración: 07:56
Puntuación: 5.00
Reproducciones: 470

Etiquetas: Application  Architect  Developer  exams  Hibernate  IRAD  JPA  mock  Portals  Rational  SCJA  SCJP  SCWCD  ServletFilter  WebSphere  

Video URL:


Insertar:

Comentarios

No comments.