different between<A Href> and <jsp: forward>

i want to access Servelt by hyperlink in a jsp web site connection.jsp

<%@ page contentType="text/html;charset=GB2312"

 %>
<HTML>
<BODY bgcolor=cyan><Font size=1>
<A Href="/myjsp/Hello"

 >Accessing servlet<A>
</BODY>
</HTML

i put the bean in the dir(/myjsp/WEB-INF/classes/hello(package)/Hello) and modify the file web.xml like this:

><servlet>
        <servlet-name>Hello</servlet-name>
        <servlet-class>hello.Hello</servlet-class>
    </servlet>
    <servlet-mapping>
  	<servlet-name>Hello</servlet-name>
  	<url-pattern>/Hello</url-pattern>
    </servlet-mapping>

it works! but if i use <jsp:forward>

<html>
	<body bgcolor="green"

>
	
	<jsp:forward page="/myjsp/Hello"

 />
	<body>
</html>

it causes an Exception The requested resource (/myjsp/myjsp/SimpleServlet) is not available.
but if you rewrite the path like this <jasp:forward page="/Hello"/> it will be ok.   why? in my opinion, if you use <A Href=..> the default path is http://localhost:8080 so you need the rest path is /myjsp/Hello. but if you use <jsp:forward> the default path is http://localhost:8080/myjsp/,so you just need write the rest part"/Hello". i don‘t know my explaination is right or not. but i think this is a try.

different between<A Href> and <jsp: forward>,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。