|
-
May 4th, 2000, 04:07 AM
#1
Servlet Servlet communication
How to send data(values in variables) from servlet1 to servlet2?
& how to read data from servlet2 sent by servlet1?
-
May 4th, 2000, 05:04 AM
#2
Re: Servlet Servlet communication
Suppose that you have two servlet, servletA and servletB. These two servlet have been initialized
in the servlet context. Suppose that servletA want to access the data in the servletB It can get the
servletB via ServletContext and access the data in the servletB. You may consider the following
code snippet :
ServletContext context = getServletContext();
ServletB servletb = (servletB)context.getServlet("servletB");
String some_data = servletb.getSomeData();
System.out.println("some data is : " + some_data);
I never try this code snippet.
For more information, you may consider the content in the Java Server Programming by wrox,
or Java Servlet Programming by oreilly.
good luck,
Alfred Wu
-
June 10th, 2000, 11:59 AM
#3
Re: Servlet Servlet communication
Hi Monika,
You may use Servlet Chaining Mechanism (and read Header Names and Header in 2nd servlet) for Chaining Output from 1st Servlet to 2nd one and so on.
C Servlet Programming by Karl Moss for more details and sample code.
Srinivas,
Columbus
-
June 12th, 2000, 07:43 AM
#4
Re: Servlet Servlet communication
Hi, U can do in this way, if ur sending 1 or 2 variables..
If this is ur form in servlet1.. then,
form name="" method="" action="http://localhost:8080/servlet/Servle...e&Name2=value2...
And in ur servlet2, access these values by,
String str1 = req.getParameter("Name");
String str2 = req.getParameter("Name2");
Hope this will help u
Sreeni
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|