Finally after about a month of certification preparation, I took the test today.

But I was lost while getting to the test site.

So here is my lesson , be fully prepared :)

And I did pass the test with the average score.

By the way the passing grade is 70.

Good Luck if you plan to take the test. Try to solve mock exams as many as possible. They do help.

Chapter 13 Filters and wrappers

Filters can intercept request before servlet and/or process reponse after servlet is completed.
Filters can be chained with other filters.
You must implement all methods : init() , doFilter() , destroy().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import javax.servlet.* ; // Filter and FilterChain are located here
public class BeerRequestFilter implements Filter {
	private FilterConfig fc;
 
	//You must implement init & destroy methods
	public void init (FilterConfig config) throws ServletException {
		this.fc=config;
	}
	// doFilter args are not HttpServletRequest and HttpServletResponse.
	public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws
			ServletException, IOException {
		HttpServletRequest httpReq = (HttpServletRequest) req; 
		// This casting is possible because the req is in fact HttpServletRequest!
 
		String name = httpReq.getRemoteUser();
		if(name != null) {
			fc.getServletContext().log("User " + name + " is updating" );
		}
		chain.doFilter(req.resp); //calling next filter
	}
	//You are required to implement destroy()
	Public void destroy(){
	}
}

Read the rest of this entry »

Chapter 11 Web Deployment

Web App Folder Structure

/myApp (.jsp , .html ) ==> /WEB-INF ==> /lib ( jar files)
/classes (class files)
/tags ( tag files)
(TLD files)

*WAR file (Web Archive) – This is in fact jar file and contains all application files including WEB-INF.
One thing special is WAR has /META-INF/MANIFEST.MF gives you deploy time check for classes & packages that WAR depends on.

*Direct access to files under WEB-INF and META-INF will show 404 error.

* <servet><url-pattern> matching order

  1. Exact match : /Beer/SelectBeear.do
  2. Directory match : /Beer/*
  3. Extension match : *.do

The most specific match always win.

*Welcome files

<welcome -file-list>
	</welcome><welcome -file>index.html</welcome>
	<welcome -file>default.jsp</welcome>

Read the rest of this entry »