did something with inner clases...
I am calling the doGet method of Servlet1 from
Servlet2
Servlet1:
package testproject2;
import java.util.*;
import java.lang.reflect.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet1 extends HttpServlet
{
static String sameer = "HELLO";
public void init(ServletConfig config) throws
ServletException {
super.init(config);
}
public void doGet(HttpServletRequest req,
HttpServletResponse res) throws ServletException,
IOException {
System.out.println("yes entering ");
// res.setContentType("text/html");
// PrintWriter out=res.getWriter();
int i = 0;
while (i < 100)
{
System.out.println("hello the value of i is :
" + i );
i ++;
}
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
public String getServletInfo() {
return "TEST SERVLET";
}
public class Innerone
{
HttpServletRequest req;
HttpServletResponse res;
public Innerone(HttpServletRequest req,
HttpServletResponse res)
{
req = this.req;
res = this.res;
}
public void runparent() throws ServletException,
IOException
{
doGet(req,res);
}
}
}
Servlet2 :
package testproject2;
import java.util.*;
import java.lang.reflect.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.kivasoft.*;
import com.kivasoft.types.*;
import com.kivasoft.util.*;
import com.kivasoft.applogic.*;
import com.netscape.server.servlet.extension.*;
public class Servlet2 extends HttpServlet
{
public void doGet(HttpServletRequest req,
HttpServletResponse res) throws ServletException,
IOException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String temp = Servlet1.sameer;
Servlet1 s1 = new Servlet1();
System.out.println("Yes Done");
testproject2.Servlet1$Innerone in = s1.new
Innerone(req,res);
System.out.println("Yes this one Done too");
in.runparent();
out.println("Yo cool");
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
Inner clases can be used as event listeners and for
Servlet to servlet communication.
Thanks
Sameer
--- Christian Cryder <[EMAIL PROTECTED]>
wrote:
> Hi Jeff,
>
> Interesting...this is exactly the train of thought
> I'm exploring right now.
> Can you share any more details? I'm working on
> building a presentation
> framework, and would like to use inner classes as
> "event listeners".
>
> I'd love to hear details if you can share them. You
> can email offline if
> that's easier ([EMAIL PROTECTED])
>
> Thanks!
> Christian
>
> > -----Original Message-----
> > From: A mailing list for discussion about Sun
> Microsystem's Java Servlet
> > API Technology.
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Jeff
> > Hanson
> > Sent: Monday, September 18, 2000 1:57 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Q: Inner classes and servlets
> >
> >
> > I worked on a team that used inner-classes to
> encapsulate particular tasks
> > associated with query parameters passed from the
> client. We were
> > designing
> > generic model-view-controller domain frameworks
> for the Web application
> > environment and this mechanism made it very easy
> for users and maintainers
> > of the frameworks to understand and modify the
> code to meet their specific
> > needs. Specifically, each domain-framework
> controller consisted of a
> > servlet or set of servlets with the tasks for the
> domain implemented as
> > inner-classes. Adding new tasks was as simple as
> adding a new inner-class
> > and associating it with a new query parameter.
> >
> > -----Original Message-----
> > From: A mailing list for discussion about Sun
> Microsystem's Java Servlet
> > API Technology.
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> > Christian Cryder
> > Sent: Monday, September 18, 2000 9:00 AM
> > To: [EMAIL PROTECTED]
> > Subject: Q: Inner classes and servlets
> >
> >
> > Hi folks,
> >
> > I'm wondering if/how people are using inner
> classes within
> > Servlets? If you
> > are, could you let me know some details?
> >
> > Thanks,
> > Christian
> > ------------------------------------------------
> > Christian Cryder
> > Software Engineer, Rocks
> > Lutris Technologies, Inc.
> > [EMAIL PROTECTED]
> > ------------------------------------------------
> > "What a great time to be a Geek"
> > ------------------------------------------------
> > http://www.lutris.com ~ http://xmlc.enhydra.org
> >
> >
>
__________________________________________________________________
> > _________
> > 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
>
>
___________________________________________________________________________
> 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
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
___________________________________________________________________________
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