hi
iam planning to do some interservlet communication
ie) calling servlet public method from another servlet
tell me the number of ways we can do interservlet communication
i want some idea regarding interservlet communication
greetings
bala
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Vikas
Paliwal
Sent: Monday, November 27, 2000 11:56 AM
To: [EMAIL PROTECTED]
Subject: RequestDispatcher: Urgent Help Needed
Hi all,
I need to forward the rquest and response objects from servlet1 to servlet2.
Servlet1 is the calling Servlet which has this code.
-----------
////////////////////////////////////////////////////////////////////////////
/////////////
RequestDispatcher dispatcher =
this.getServletContext().getRequestDispatcher("/overhaul/jservlet/CalledServ
let");
if(dispatcher != null)
dispatcher.forward(req,res);
////////////////////////////////////////////////////////////////////////////
/////////////
Servlet2 is a simple called servlet which does the req.getParameter of the
first servlet Values
------------
////////////////////////////////////////////////////////////////////////////
///////////////
package jservlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class CalledServlet extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws
ServletException,IOException
{
doPost(req,res);
}
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws
ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out = new PrintWriter(res.getWriter());
StringBuffer lstrDisplayHTML = new StringBuffer();
lstrDisplayHTML.append("<HTML>");
lstrDisplayHTML.append("<HEAD>");
lstrDisplayHTML.append("<TITLE>Calling Servlet </TITLE>");
lstrDisplayHTML.append("</HEAD>");
lstrDisplayHTML.append("<BODY>");
lstrDisplayHTML.append("<FORM NAME=frmTest METHOD='POST' >");
lstrDisplayHTML.append("<P> New Servlet Called");
lstrDisplayHTML.append("</FORM>");
lstrDisplayHTML.append("Request" + req.getParameter("txtMode") +
req.getParameter("txtfield1"));
lstrDisplayHTML.append("</BODY>");
lstrDisplayHTML.append("</HTML>");
out.println(lstrDisplayHTML.toString());
out.close();
}
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////
These servlets in the current state work perfectly alright and do the
needful.
But If I remove the "package jservlet;" line from the second servlet code
It
stops working and an application error is thrown.
Both my servlets are in jservlet folder.
Am testing these under Oracle Application Server.
Somebody please help...Why this strange behaviour? How is the Called Servlet
path is related to Package keyword?
Also note that I have not put the package statement in the first servlet and
it
works perfectly alright.
How exactly does the package <packagename> work?
I have not defined a package for the rest of the servlets and hence I want
to
know if its possible
without using the package keyword.
Thanks in advance,
Vikas
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html