| Author |
invoking servlet from another servlet
|
indra sen
Greenhorn
Joined: Jun 08, 2007
Posts: 27
|
|
I want to invoke face servlet from login servlet. here is the web.xml file <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>login.LoginServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> I have tried request.getRequestDispatcher("/Faces Servlet"); and this.getServletContext().getRequestDispatcher("javax.faces.webapp.FacesServlet")); both are returing null.can anybody help me... Thanks in advance...
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
I think the whitespace in "Faces Servlet" might cause this harm. Can you try removing the space (and it should look as that of LoginServlet) and run again? For the second part, try replacing the "." with "/" but the path should be relative to the context root.
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
|
Where are the URL mappings for the servlets?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
Originally posted by Raghavan Muthu: I think the whitespace in "Faces Servlet" might cause this harm.
I guess servlet name can contain spaces.Leading and trailing spaces are ignored.
|
Rahul Bhattacharjee
LinkedIn - Blog
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
you cannot use /Faces Servlet.. its the servlet name. What have you put in servlet-mapping ?
|
 |
indra sen
Greenhorn
Joined: Jun 08, 2007
Posts: 27
|
|
<servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>login.LoginServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> request.getRequestDispatcher(path); and this.getServletContext().getRequestDispatcher(path); So, path means the <servlet-name> or <servlet-class> from web.xml?
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
No, see there is another <servlet-mapping> tag <servlet-mapping> <servlet-name>XYZ Servlet</servlet-name> <url-pattern>/xyzservlet</url-pattern> <servlet-mapping> now you use /xyzservlet foe getting the request dispatcher. Try this and see if it solves your problem.
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
Another thing, The <servlet-name> of <servlet-mapping> should match the <servlet-name> of <servlet> tag..
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Originally posted by Rahul Bhattacharjee: I guess servlet name can contain spaces.Leading and trailing spaces are ignored.
Thanks for the info Rahul. Let me try it out.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
|
I ask again, where are the URL mappings for the servlet? Why are you ignorning my and Amol Nayak's replies?
|
 |
indra sen
Greenhorn
Joined: Jun 08, 2007
Posts: 27
|
|
Thanks Amol ,it works .... so it is the servlet mapping in web.xml
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1334
|
|
"indraNJ sen", Please check your private messages for an important message from me. Kind regards, Katrina Owen, JavaRanch Saloon Bartender
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
Hi, Check this SayThanks]http://faq.javaranch.com/view?SayThanks]SayThanks[/url][/url] Even if one particular solution helped you fix your problem, please say thanks to everyone saying which solution helped you.. Cheers.
|
 |
 |
|
|
subject: invoking servlet from another servlet
|
|
|