본문 바로가기

프로그래밍/Servlet

[servlet] 경로 맞추기


'web.xml' 'servlet class' 'html action'

요 세개사이의 연결이 참으로 짜증나게.. 안맞아서 너무너무 고민했다.

html 페이지에서 버튼 클릭이 일어나면 보통 <form 태그를 통해서 action으로 해당 서블릿을 찾게된다. 그 사이에서 조정해 주는것이 바로 web.xml의 내용이란 말씀.



action -> web.xml -> servlet class

[html file]
action="TestServlet" 였다면

[web.xml]
SampleClass의 이름을 가진 url-pattern을 찾아서

같은 servlet-name을 가진 servlet-class를 찾아간다.
	
		Hello
		com.servlet.test.TestServlet
	
	
		Hello
		/TestServlet
	
그리고 옵션으로 action에서 지정한 method 형식대로 doGet 또는 doPost를 실행한다.



 

'프로그래밍 > Servlet' 카테고리의 다른 글

[Servlet] 처음에 여러가지 어려운 것 들  (0) 2012.02.28
[Servlet] 기본  (0) 2012.02.27