如何应对web context root的改变

如题
比如我一开始设置为 /reg,我登录访问的是 /reg/index.jsp,这样我页面里的 image 就是 /reg/images/1.gif
如果设置改为 /, 那我登录访问的就是 /index.jsp,这样我页面里的 image 就是 /images/1.gif

目前使用的应对方法是:
[code="java"]String contextPath = request.getContextPath();[/code]
[code="html"]<%= contextPath %>/images/1.gif[/code]

请问有没有更好的,这样我在Dreamweaver中就能显示图片了

使用相对路径

[code="html"][/code]

/level2/index.jsp 就用

[code="html"][/code]