Computer

Computer

View Answers

July 22, 2008 at 5:15 PM

hi friend,

package javacode;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ForwardServlet extends HttpServlet{
private static final String forwardTo = "/jsp/ResultServlets";
private static final String includeIn = "/jsp/ResultServlets";

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.print("<html><head><style>");
out.print("p,form{font-family:tahoma;font-size:10pt;}");
out.print("input{width:20;height:20;}");
out.print("</style></head><body>");

// Displaying Form
out.print("<form action=\"");
out.print( req.getRequestURI() );
out.print("\" method=\"post\">");
out.print("<input type=\"hidden\" name=\"mode\" ");
out.print("value=\"forward\">");
out.print("<input type=\"submit\" value=\" \"");
out.print("> ");
out.print(" Forward to another Servlet ..");
out.print("</form>");
out.print("<form action=\"");
out.print( req.getRequestURI() );
out.print("\" method=\"post\">");
out.print("<input type=\"hidden\" name=\"mode\" ");
out.print("value=\"include\">");
out.print("<input type=\"submit\" ");
out.print("value=\" \"> ");
out.print(" Include another Servlet ..");
out.print("</form>");
out.print("</body></html>");
out.close();
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

String mode = req.getParameter("mode");
// Forwarding to Servlet2
if(mode != null && mode.equals("forward")) {
req.setAttribute("mode", "Forwarding Response..");
req.getRequestDispatcher(forwardTo).forward(req, res);
}
// Including response from Servlet2
if(mode != null && mode.equals("include")) {
req.setAttribute("mode", "Including Response..");
req.getRequestDispatcher(includeIn).include(req, res);
}
}
}

-------------------------------------------------

package javacode;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ResultServlets extends HttpServlet{

public void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Hello World</title></title>");
out.println("<body>");
out.println("<h1>Welcome to Roseindia</h1>");
out.println("</body></html>");

}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String mode = req.getParameter("mode");
// Forwarding to Servlet2
if(mode != null && mode.equals("forward")) {
req.setAttribute("mode", "Forwarding Response..");
}
// Including response from Servlet2
if(mode != null && mode.equals("include")) {
req.setAttribute("mode", "Including Response..");

}
}
}

--------------------
Read for more information.

http://www.roseindia.net/servlets


Thanks









Related Tutorials/Questions & Answers:
computer
Computer Networks
Computer Networks  The IPV4 packet has arrived wtih first few hexadecimal digits as 0X45000028000100000102. How many hopes will this packet travel before being dropped
Advertisements
computer science
computer science  Objective:Work with hash tables by creating a hash table using linear probing. I need this code in java. "LinearProbingHashTable.java" Description:Create a generic class called LinearProbingHashTable<K,V>
Computer Networking
Computer Networking   ... a commercial activity where you were using a computer along with a printer... the sharing and exchanging facilities among the computer machines is called
basic function of computer system
basic function of computer system  What is the basic function of computer system
Computer Terminology Bug
Computer Terminology Bug  What is mean by bug in computer terminology
Computer Terminology Bug
Computer Terminology Bug  What is mean by bug in computer terminology
Define computer software.
Define computer software.  How to define a computer software?   A computer software is a set of instruction that tell the computer what to do
Computer forensic application
Computer forensic application  how to write computer forensic application using java for recovering deleted files and deleted partitions
ModuleNotFoundError: No module named 'computer'
ModuleNotFoundError: No module named 'computer'  Hi, My Python... 'computer' How to remove the ModuleNotFoundError: No module named 'computer... to install padas library. You can install computer python with following
ModuleNotFoundError: No module named 'computer'
ModuleNotFoundError: No module named 'computer'  Hi, My Python... 'computer' How to remove the ModuleNotFoundError: No module named 'computer... to install padas library. You can install computer python with following
Computer shop mangerment
Computer shop mangerment   Part A You are supposed to write a class Computer to stores the computer id, description, brand, price, speed and another... of it. Part B Develop array based java program to help a local computer shop
List of Computer Software
List of Computer Software  Hi, I am looking for the list of Computer programming languages. Provide me the list of Computer Software used these days... for different purposes. See the List of Computer software. Thanks
computer - Swing AWT
computer  What is a Computer and why we should use it? I am new to this technologies so please let me know the benefits of using computer.   What you what to know about computers?Is it a software or hardware related
The input device used by computer is
The input device used by computer is  The input device used by computer is 1. Motherboard 2. Central Processing Unit 3. Keyboard 4. System Unit 5. All of the above   Answer: 2. Central Processing Unit
a computer network is referred as
a computer network is referred as  The structure of interconnecting of nodes of --- a computer network is referred as 1. Network topology 2. Internet 3. Local Area network 4. Wide Area network 5. All of these   Answer
computer management - Java Beginners
computer management  Create a class Computer that stores information... to be stored about a single computer is, - Company Name - RAM size... array of 4 objects of Computer class and that takes input for all above
computer configuration - Java Beginners
computer configuration  someone posted a code but tha is not working... a working code Create a class Computer that stores information about... about a single computer is, - Company Name - RAM size. - Hard Disk Capacity
ALU Computer Term
ALU Computer Term  What is ALU? Please define and explain ALU in simple language.   ALU stands for Arithmetic logic unit is a brain of CPU, which is used for the processing of data and information provided
characteristics of a modem computer
characteristics of a modem computer  Which of the following describe one or more characteristics of a modem computer? 1. An electronic device 2. A mechanical device 3. A Electro-mechanical device 4. All of these 5. None
Computer security - Security
computer security advice  Can any one give me a computer security advice? Thanks!  Please take care whenever you are formatting your hard drive as when you format a hard drive, you erase all its files and prepare
data analysis computer science
data analysis computer science  Hi, I am beginner in Data Science... analysis computer science Try to provide me good examples or tutorials links so that I can learn the topic "data analysis computer science". Also tell
computer science with artificial intelligence
computer science with artificial intelligence  Hi, I am beginner... to learn: computer science with artificial intelligence Try to provide me good examples or tutorials links so that I can learn the topic "computer science
nvidia computer vision course
nvidia computer vision course  Hi, I am beginner in Data Science... computer vision course Try to provide me good examples or tutorials links so that I can learn the topic "nvidia computer vision course". Also tell me
computer vision stanford course
computer vision stanford course  Hi, I am beginner in Data Science...: computer vision stanford course Try to provide me good examples or tutorials links so that I can learn the topic "computer vision stanford course". Also
learn computer vision python
learn computer vision python  Hi, I am beginner in Data Science... computer vision python Try to provide me good examples or tutorials links so that I can learn the topic "learn computer vision python". Also tell me
Is Masters in computer science difficult?
Is Masters in computer science difficult?  Hi, I am beginner in Data...: Is Masters in computer science difficult? Try to provide me good examples or tutorials links so that I can learn the topic "Is Masters in computer
Getting Computer Date in java
Getting Computer Date in java  Hi , I want to get the PC Date and insert it to a DB, specifically MSSQL.. Everything in my scriptlet works but this.. String strDate = new Date(); I get this server error, "The type Date
java with computer network
java with computer network  i feel it's very difficult to use java for network programming. how can i recover this problem?give me any simple example with explanation.   hi, if you want to make carrier in software
computer manufacture case study
computer manufacture case study  Computer Manufacturer Case Study BNM is an upcoming computer manufacturer. The company was making a mark in the desktop and laptop segment due to aggressive pricing and good products. The sales
ModuleNotFoundError: No module named 'computer-vision'
ModuleNotFoundError: No module named 'computer-vision'  Hi, My... named 'computer-vision' How to remove the ModuleNotFoundError: No module named 'computer-vision' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'computer-model'
ModuleNotFoundError: No module named 'computer-model'  Hi, My... named 'computer-model' How to remove the ModuleNotFoundError: No module named 'computer-model' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'computer-model'
ModuleNotFoundError: No module named 'computer-model'  Hi, My... named 'computer-model' How to remove the ModuleNotFoundError: No module named 'computer-model' error? Thanks   Hi, In your python
different types of storage devices of a computer
different types of storage devices of a computer  What are the different types of storage devices of a computer?   Magnetic disks, Tapes and DVDs are few examples of storage devices of a computer
Computer dealer management - Java Beginners
Computer dealer management  Create a class Computer that stores.... The information to be stored about a single computer is, - Company Name - RAM size... ( ) method that creates array of 4 objects of Computer class and that takes input for all
Computer Scince 1015 - Java Beginners
Computer Scince 1015  Write a SavingsAccount class to store the following information related to a bank account: Account number, Password, Branch name, Surnames, First names, Balance The account balance should be able
master of computer science in data science
master of computer science in data science  Hi, I am beginner... to learn: master of computer science in data science Try to provide me good examples or tutorials links so that I can learn the topic "master of computer
computer science economics and data science
computer science economics and data science  Hi, I am beginner... to learn: computer science economics and data science Try to provide me good examples or tutorials links so that I can learn the topic "computer science
computer science and artificial intelligence degree
computer science and artificial intelligence degree  Hi, I am... for the tutorials to learn: computer science and artificial intelligence degree Try to provide...;computer science and artificial intelligence degree". Also tell me which
computer science artificial intelligence course
computer science artificial intelligence course  Hi, I am beginner... to learn: computer science artificial intelligence course Try to provide me good examples or tutorials links so that I can learn the topic "computer
computer science artificial intelligence degree
computer science artificial intelligence degree  Hi, I am beginner... to learn: computer science artificial intelligence degree Try to provide me good examples or tutorials links so that I can learn the topic "computer
masters in computer science artificial intelligence
masters in computer science artificial intelligence  Hi, I am... for the tutorials to learn: masters in computer science artificial intelligence Try to provide...;masters in computer science artificial intelligence". Also tell me which
bsc computer science with artificial intelligence
bsc computer science with artificial intelligence  Hi, I am beginner... to learn: bsc computer science with artificial intelligence Try to provide me... computer science with artificial intelligence". Also tell me which is the good
phd computer science artificial intelligence
phd computer science artificial intelligence  Hi, I am beginner... to learn: phd computer science artificial intelligence Try to provide me good examples or tutorials links so that I can learn the topic "phd computer
ms in computer science data analytics
ms in computer science data analytics  Hi, I am beginner in Data...: ms in computer science data analytics Try to provide me good examples or tutorials links so that I can learn the topic "ms in computer science data
coursera deep learning in computer vision
coursera deep learning in computer vision  Hi, I am beginner in Data...: coursera deep learning in computer vision Try to provide me good examples... in computer vision". Also tell me which is the good training courses
deep learning computer vision course
deep learning computer vision course  Hi, I am beginner in Data...: deep learning computer vision course Try to provide me good examples or tutorials links so that I can learn the topic "deep learning computer vision
udemy deep learning computer vision
udemy deep learning computer vision  Hi, I am beginner in Data...: udemy deep learning computer vision Try to provide me good examples or tutorials links so that I can learn the topic "udemy deep learning computer
advanced computer vision and deep learning
advanced computer vision and deep learning  Hi, I am beginner... to learn: advanced computer vision and deep learning Try to provide me good examples or tutorials links so that I can learn the topic "advanced computer
computer vision deep learning jobs
computer vision deep learning jobs  Hi, I am beginner in Data...: computer vision deep learning jobs Try to provide me good examples or tutorials links so that I can learn the topic "computer vision deep learning jobs"

Ads