[drp]-index.jsp page to another page servlet how to configure

Source: Internet
Author: User

JSP page

<%@ Page Language="Java"Import="java.util.*"pageencoding="GB18030"%><%StringPath=Request.getcontextpath ();StringBasePath=Request.getscheme ()+"://"+Request.getservername ()+":"+Request.getserverport ()+Path+"/";%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML>  <Head><%--     <Base href="<%=basePath%>"> --%>        <title>My JSP ' index.jsp ' starting page</title>    <Metahttp-equiv= "Pragma"content= "No-cache">    <Metahttp-equiv= "Cache-control"content= "No-cache">    <Metahttp-equiv= "Expires"content= "0">        <Metahttp-equiv= "keywords"content= "Keyword1,keyword2,keyword3">    <Metahttp-equiv= "description"content= "This is my page">    <!--<link rel= "stylesheet" type= "Text/css " href= "Styles.css" > -  </Head>    <Body>   <ahref= "Servlet/jstlelservlet">Test El Expression</a><BR>  </Body></HTML>

Then go to Web. Xml to find:

<?XML version= "1.0" encoding= "UTF-8"?><Web-appversion= "2.4"xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">    <servlet>        <Servlet-name>Jstlelservlet</Servlet-name>        <Servlet-class>Com.bjpowernode.jstl.JstlElServlet</Servlet-class>    </servlet>            <servlet-mapping>        <Servlet-name>Jstlelservlet</Servlet-name>        <Url-pattern>/servlet/jstlelservlet</Url-pattern>            </servlet-mapping>    </Web-app>

Then find the Java class:

 PackageCom.bjpowernode.jstl;Importjava.io.IOException;Importjavax.servlet.ServletException;ImportJavax.servlet.http.HttpServlet;Importjavax.servlet.http.HttpServletRequest;ImportJavax.servlet.http.HttpServletResponse; Public classJstlelservletextendsHttpServlet {@Overrideprotected voiddoget (httpservletrequest request, httpservletresponse response)throwsservletexception, IOException {request.setattribute ("Hello", "Hello World"); Request.getrequestdispatcher ("/web-inf/jstl_el.jsp"). Forward (request, response); }}

Jump to jstl_jsp page

<%@ Page Language="Java"ContentType="text/html; charset=gb18030"pageencoding="GB18030"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=gb18030"><title>Insert Title here</title></Head><Body>   <H1>Test El Expression</H1>   <HR>   <Li>Normal string</Li><BR>hell0 (JSP footsteps):<%=Request.getattribute ("Hello") %><BR></Body></HTML>

Summary: Try to make those who despise you, abandon you regret!

[drp]-index.jsp page to another page servlet how to configure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.