RequestDispatcher include Example
Create Following Files
- Create web application [ RequestDispatcherDemo ]
- header.jsp
- footer.jsp
- body.jsp
- style.css
- In web application directory create [ RequestDispatcherDemo \ WEB-INF ] directory
- create web.xml file
- Create directory [ RequestDispacherDemo \ WEB-INF \ classes ]
- compile RequestDispacherDemo.java and upload RequestDispacher.class
header.jsp
<html>
<head>
<LINK REL="STYLESHEET" HREF="style.css" TYPE="text/css">
</head>
<body bgcolor="#ababab">
<div class="header">header</div>
</body>
</html>
<head>
<LINK REL="STYLESHEET" HREF="style.css" TYPE="text/css">
</head>
<body bgcolor="#ababab">
<div class="header">header</div>
</body>
</html>
footer.jsp
<div class="footer">footer</div>
body.jsp
<div class="body">body</div>
style.css
.header
{
left:20%;
height:20%;
width:60%;
position:absolute;
background:#f99000;
text-align:center;
padding:5px;
}
.body
{
top:20%;
left:20%;
height:60%;
width:60%;
position:absolute;
background:#ffffff;
text-align:center;
padding:5px;
}
.footer
{
top:80%;
left:20%;
height:20%;
width:60%;
position:absolute;
background:#a1a000;
text-align:center;
padding:5px;
}
{
left:20%;
height:20%;
width:60%;
position:absolute;
background:#f99000;
text-align:center;
padding:5px;
}
.body
{
top:20%;
left:20%;
height:60%;
width:60%;
position:absolute;
background:#ffffff;
text-align:center;
padding:5px;
}
.footer
{
top:80%;
left:20%;
height:20%;
width:60%;
position:absolute;
background:#a1a000;
text-align:center;
padding:5px;
}
RequestDispatcherDemo.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RequestDispacherDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
RequestDispatcher dispatcher;
dispatcher = request.getRequestDispatcher("header.jsp");
dispatcher.include(request, response);
dispatcher = request.getRequestDispatcher("body.jsp");
dispatcher.include(request, response);
dispatcher = request.getRequestDispatcher("footer.jsp");
dispatcher.include(request, response);
}
}
import javax.servlet.*;
import javax.servlet.http.*;
public class RequestDispacherDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
RequestDispatcher dispatcher;
dispatcher = request.getRequestDispatcher("header.jsp");
dispatcher.include(request, response);
dispatcher = request.getRequestDispatcher("body.jsp");
dispatcher.include(request, response);
dispatcher = request.getRequestDispatcher("footer.jsp");
dispatcher.include(request, response);
}
}
web.xml
<web-app>
<servlet>
<servlet-name>RequestDispacherDemo</servlet-name>
<servlet-class>RequestDispacherDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestDispacherDemo</servlet-name>
<url-pattern>/index.html</url-pattern>
</servlet-mapping>
</web-app>
<servlet>
<servlet-name>RequestDispacherDemo</servlet-name>
<servlet-class>RequestDispacherDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestDispacherDemo</servlet-name>
<url-pattern>/index.html</url-pattern>
</servlet-mapping>
</web-app>
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
0 comments:
Post a Comment