java servlets

java servlets

View Answers

September 11, 2008 at 11:19 AM

Hi friend,


Sending request one servlet to another servlet.

first servlet "MyServlet"

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet {
public void doGet (HttpServletRequest request,HttpServletResponse response) {

try {
doPost(request, response);
}
catch (Exception ex) {
ex.printStackTrace ();
}
}

public void doPost (HttpServletRequest request,HttpServletResponse response) {

try {
getServletConfig().getServletContext().getRequestDispatcher("/myServlet2").forward(request, response);
}
catch (Exception ex) {
ex.printStackTrace ();
}
}
}

forward to another servlet "MyServlet2"

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet2 extends HttpServlet {

public void doGet (HttpServletRequest request,HttpServletResponse response) {

try {
doPost(request, response);
}
catch (Exception ex) {
ex.printStackTrace ();
}
}

public void doPost (HttpServletRequest request,HttpServletResponse response) {
try {
PrintWriter out = response.getWriter();
out.println("Another Servlet");
}
catch (Exception ex) {
ex.printStackTrace ();
}
}
}

mapping for servlet in web.xml

<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/myServlet</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>myservlet2</servlet-name>
<servlet-class>MyServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet2</servlet-name>
<url-pattern>/myServlet2</url-pattern>
</servlet-mapping>

For any more problem give in details and visit.....

http://roseindia.net/servlets/

Thanks









Related Tutorials/Questions & Answers:
java servlets
java servlets  please help... how to connect java servlets with mysql i am using apache tomcat 5.5
Java Servlets
Java Servlets  If the binary data is posted by both doGet and doPost then which one is efficient?Please give me some example by using both doGet and doPost. Thanks in Advance   The doPost method is more efficient
Advertisements
servlets - Java Beginners
to respond to HTTP requests. A JSP layered on top of Java Servlets. Whereas...servlets  what is the difference b/w servlets and JSP, what servlets..., The Java Servlet is the fundamental component to using Java for web
java servlets - Java Beginners
java servlets  hai my question is on xml documentation in creation of a java servlets. whether we have to create for each and every servelet we have to create each xml documentation?   Hi friends Exactly what you
Servlets
Servlets  Java Servlet technology  You have set.... Anyways, please visit the following links: http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http://www.roseindia.net/servlets
servlets - Java Beginners
servlets   I am doing small project in java on servlets. I want to generate reports on webpage ,how is it possible and what is the difference between dynamic pages & reports ? tell me very urgent pls,pls
servlets
servlets  why we are using servlets
servlets
servlets  what is the duties of response object in servlets
servlets
what are advantages of servlets  what are advantages of servlets   Please visit the following link: Advantages Of Servlets
Servlets - Java Beginners
Servlets  Hi, How can i run the servlet programon my system? I wrote the code in java.(I've taken the Helloworld program as example program... for more information, http://www.roseindia.net/servlets/ Thanks Amardeep
servlets - Java Interview Questions
html and processing in servlets and store in DB like ORACLE. And next i want to retrieve this image into web page using servlets. please try to send the answer to me servlets. i was not strong otherthan this. so please send me answer using
java servlets jdbc - JDBC
java servlets jdbc  i am running the servlet program with jdbc connections in this porgram i used two 'esultset' objects.. in this wat ever coding is available in the first resultset is executed like updating and retrieiving
Servlets
Servlets  How to edit and delete a row from the existing table in servlets
servlets
servlets  How do you communicate between the servlets?   We can communicate between servlets by using RequestDespatcher interface and servlet chaining
servlets bulk - Java Beginners
servlets bulk  Hi, My problem is " i want to send a one mail to many persons(i.e.,same mail to many persons) using servlets". Pls help me.  Hi Friend, Please visit the following links: http
servlets mails - Java Beginners
servlets mails  Hi, My problem is " i want to send a one mail to many persons(i.e.,same mail to many persons) using servlets". Pls help me.  Hi Friend, Please visit the following links: http
servlets
what is the architecture of a servlets package  what is the architecture of a servlets package   The javax.servlet package provides interfaces and classes for writing servlets. The Servlet Interface The central
java Servlets - JSP-Servlet
java Servlets  Hi i am having a doubt regarding servlets as i am in learning stage give me any clew how to retrive data from mysql database after getting data from db and again i have to add that data to textbox using html
Servlets
Servlets  How to check,whether the user is logged in or not in servlets to disply the home page
servlets - Java Beginners
servlets   Q: i write program to upload image into perticular folder.but i want to store that path into database but not image and display that image in page from the db.pls any one send me code for that in servlets asap.pls
Servlets - Java Interview Questions
and are available to all the servlets within that application. It represents your web... are specified for a particular servlet and are unknown to other servlets... information visit to : http://www.roseindia.net/servlets/ServletContext.shtml
servlets - Java Beginners
servlets  Hello! am doin my servlet course at niit, i want know in detail methods of servlets,and where can we implement it i.e. i want to know the examples of the methods used in it. what is getInParameter(); does.please
servlets
servlets  why we require wrappers in servlets? what are its uses? Please explain   These wrappers classes help you to modify request...://www.roseindia.net/servlets/response-filte.shtml
servlets
servlets  How to open and read the contents of a text file in servlets?   Please visit the following link: Read text file using Servlet
servlets deploying - Java Beginners
servlets deploying  how to deploy the servlets using tomcat?can you...); } } -------------------------------------------------------  This is servlets.... http://www.roseindia.net/servlets Thanks Amardeep
servlets
what are filters in java servlets  what are filters in java   Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing request and response paradigm
servlets
servlets   Hi what is pre initialized servlets, how can we achives?   When servlet container is loaded, all the servlets defined in the web.xml file does not initialized by default. But the container receives
servlets
servlets why do we need web-inf directory in web application  why do we need web-inf directory in web application? means what's the benefits of doing so
Servlets and
Servlets and   Sir...! I want to insert or delete records form oracle based on the value of confirm box can you please give me the idea.... thanks
java servlets with database interaction
java servlets with database interaction  hai friends i am doing a web application in that i have a registration page, after successfully registered it has to display a message like "you have successfully registered" and those
servlets
which are the differ ways you can communicat between servlets  which are the differ ways you can communicat between servlets   Different ways of communicating between servlets:- 1)Using RequestDispatcher object. 2
servlets
package supports the development of servlets that use the HTTP protocol. The classes... javax.servlet.GenericServlet and serves as the base class for HTTP servlets. HttpServlet-Request
servlets
what are sessions in servlets  what are sessions in servlets   A Session refers to all the request that a single client makes to a server...: http://roseindia.net/jsp/jspsession/ http://www.roseindia.net/servlets
the servlets
what is diff between generic servlets and httpservlets  what is diff between generic servlets and httpservlets   Difference between GenericServlet and HTTPServlet: 1)GenericServlet belongs to javax.servlet package
servlets
regarding the user usage and habits. Servlets sends cookies to the browser client...://www.roseindia.net/jsp/jspcookies.shtml http://www.roseindia.net/servlets/use
java servlets - Java Beginners
java servlets  i want to close window when ever he logout from one page... this closing is done with yes/no option. when ever press "yes" it means he successfully logout from page. if press "no" it means he not logout from
servlets
servlets  hi i am using servlets i have a problem in doing an application. in my application i have html form, in which i have to insert on date value, this date value is retrieved as a request parameter in my servlet
java struts servlets writing - Struts
java struts servlets writing  sir..i am using eclipse here for software development.and i just want to know what all are the neccessary steps to write servlets pragrams for stuts applicatuin.here am developing a small application
java servlets - JSP-Servlet
java servlets  how to get the parameter value of input type file using java servlets  Hi, You can use request.getParameter(). In Jsp, --- --- IN servlet, String fileName=request.getParameter('fl'); If you
java servlets - JSP-Servlet
java servlets  I am using eclipse . please help me to write a web application that follows mvc architecture and use jdbc connection pooling for oracle 10g
java-servlets - JSP-Servlet
java-servlets  I have one doubt.if we update resume in jobportal websites, at that place i saw only some fields are possible to edit at a time. how is it possible. pls clarify my doubt any one. I will be thankful to you
servlets
servlets  what are different authentication options available in servlets   There are four ways of authentication:- HTTP basic authentication HTTP digest authentication HTTPS client authentication Form-based
java servlets - JDBC
java servlets  First thank you sir for your reply sir i am using "Oracle Database" it asking for 1.User Name 2.Password 3.Host String if we doesn't give that "Host String" it doesn't connecting to the Oracle.In
servlets
, visit the following links: http://www.roseindia.net/help/java/d/requestdispatcher.shtml http://www.roseindia.net/tutorial/java/servlet/httprequest
servlets
servlets  what is ResultSet?   ResultSet is a java object that is used for database connectivity to hold the data returned by a select query. When we run a select query it returns us the data in a table format with each
servlets
the following links: http://www.roseindia.net/tutorial/java/jsp/URLrewriting.html
servlets
servlets  how can I run java servlet thread safety program using tomcat server? please give me a step by step procedure to run the following program my program is A DEMO PROGRAM FOR THREAD SAFETY. package serv; import
Java Servlets - Java Interview Questions
Java Servlets  1.What is Pojo class? How and where it is used? 2.Can... where can i download NetBean 5.5.1?  Pojo class is normal java... " THE JAVA CLASS CANNNOT EXTENDS ANY PREDEFINED THIRDPARTY API CLASS OR INTERFACE". 3
Use Java Bean In Servlets
Use Java Bean In Servlets In this you will learn how to use Java Bean in Servlets. For this purpose, we have created a Bean named 'Person' and defined three variables with their setters and getters. Then we have created an object
java servlets - Servlet Interview Questions
java servlets  is it possible sending requestdispatcher from one page to onther page means here in the first servlet i am using doPost() method...://roseindia.net/servlets/ Thanks

Ads