different between<A Href> and <jsp: forward>
2014-03-18 16:06
211 查看
i want to access Servelt by hyperlink in a jsp web site connection.jsp
i put the bean in the dir(/myjsp/WEB-INF/classes/hello(package)/Hello) and modify the file web.xml like this:
it works! but if i use <jsp:forward>
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.
<%@ 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.
相关文章推荐
- <jsp:forward>与response.sendRedirect()的区别
- java中使用<jsp:forward>报404错误
- jsp动作元素:<jsp:forward>动作元素
- JSP<jsp:forward>与<%@ include%>
- jsp中运用<a href>传参
- 3.Struts的<action forward="/login.jsp"></action>:web.xml
- [JSP]标准标签、<jsp:include、forward、param、useBean、setProperty、getProperty>
- jsp跳转标签<jsp:forward>
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- 转载:如何理解jsp页面中的“<base href="<%=basePath%>">”?
- (6)开发收获 <base href="<%=basePath%>">JSP页面中的相对路径问题
- <jsp:forward>标签跳转指令和response.sendRedirect()跳转指令的区别
- JSP中<base href="<%=basePath%>">作用
- jsp中<a href=""></a>标签传递参数乱码问题解决
- JSP中<base href="<%=basePath%>">的作用
- 2.Struts的<action forward="/login.jsp"></action>:struts-config.xml
- JSP中<base href="<%=basePath%>">作用
- <jsp:include>与<jsp:forward>