File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes i can't understand this sentence ~~please help me,thanks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "i can Watch "i can New topic
Author

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

Tu Ran
Ranch Hand

Joined: Feb 09, 2002
Posts: 30
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


Enjoy java,enjoy life
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
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


Java Resources at www.wbrogden.com
Tu Ran
Ranch Hand

Joined: Feb 09, 2002
Posts: 30
William Brogden
Thanks for your answer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i can't understand this sentence ~~please help me,thanks
 
Similar Threads
Question getServletContext().getRequestDispatcher("/foo.jsp").forward(req, res); I
How can I run this sample code?
want to pass a string to a servlet
More simple doubts....errr
Calling getRequestDispatcher method ??