Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i can't understand this sentence ~~please help me,thanks

 
Tu Ran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class toServlet1 extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws IOException,ServletException{
try{
<font color="red">this.getServletConfig().getServletContext().
getRequestDispatcher("/x1.jsp").forward(req,res);</font>
}catch(Exception e){
e.printStackTrace();
}
}
}
//i can' understand this sentence:
this.getServletConfig().getServletContext().
getRequestDispatcher("/x1.jsp").forward(req,res);
//please explain i ,thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet inherits the getServletConfig() method from GenericServlet. This statement gets the ServletConfig object for this instance and calls getServletContext() to get the ServletContext object - that is the context that all servlets in your application operate under.
Finally the getRequestDispatcher method of ServletContext is called to get the associated RequestDispatcher. RequestDispatcher has a forward method which is called.
Bill
 
Tu Ran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden
Thanks for your answer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic