A
Andrew Purser
As you can tell by my subject line I am fairly new to java and
servlets.
I was hoping I could get some feed back as to the merits / problems /
suggestions of other ways to do it for the code skeleton below.
Basically I have created a Something java class that I want to call
from a servlet. The catch is I want the Something java class to
include Jsps depending on various things. The only way I can see to do
this if for my servlet to pass the ServletContext, HttpRequest and
HttpResponse to the class. I get the feeling this may be a bad thing
to do. Can someone enlighten me?
Cheers,
Andrew.
Code outline :
public class Something {
public void buildPage(ServletContext context,
HttpServletRequest req,
HttpServletResponse res) {
// do various bits and pieces to work out what page
// to include.
context.getRequestDispatcher(jspToInlucde).include(req,res);
}
}
public class MyServlet extends HttpServlet {
doPost() {
Something.buildPage(context,request,response);
}
}
servlets.
I was hoping I could get some feed back as to the merits / problems /
suggestions of other ways to do it for the code skeleton below.
Basically I have created a Something java class that I want to call
from a servlet. The catch is I want the Something java class to
include Jsps depending on various things. The only way I can see to do
this if for my servlet to pass the ServletContext, HttpRequest and
HttpResponse to the class. I get the feeling this may be a bad thing
to do. Can someone enlighten me?
Cheers,
Andrew.
Code outline :
public class Something {
public void buildPage(ServletContext context,
HttpServletRequest req,
HttpServletResponse res) {
// do various bits and pieces to work out what page
// to include.
context.getRequestDispatcher(jspToInlucde).include(req,res);
}
}
public class MyServlet extends HttpServlet {
doPost() {
Something.buildPage(context,request,response);
}
}