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 getRequestDispatcher problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getRequestDispatcher problem" Watch "getRequestDispatcher problem" New topic
Author

getRequestDispatcher problem

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
hi
i have a jsp page(emp.jsp);in that jsp i am calling servlet like this;
<form action="servlet/EmpServlet">
i will add employee objects into list;i will pass this listing to jsp page there i will print the employee objects;
list.add(EmpObjects);
request.setAttribute("emp",list);
getServletContext().getRequestDispatcher("emp.jsp").forward(request,response);
the request object is going to the jsp page and also i am able to print values there in jsp but the URL on the address bar is coming like this http://localhost/example/servlet/EmpServlet.But the url i want is
http://localhost/example/Emp.jsp;
bye
chaitanya
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Won't happen. The forward is completely invisible to the browser. All it knows about is the request it originally submitted.
Why do you care what's showing in the URL?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
Your question demonstrates a lack of fundamental understanding. I don't mean that as a flame in any way, either. I was there at one point, too.
For a basic understanding of how servlets, JSPs, and HTTP work, I recommend Core Servlets and JavaServer Pages. That's what I first learned from.


comp.lang.javascript FAQ: http://jibbering.com/faq/
Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64
Hi Chaitanya,
The forward(..) method will forwards the request on behalf of the main servlet.
It is like 'i don't have the functionality..so bring it from other..and give it to the requested person'.
So,the requested person(browser) doesn't know that we are taking or forwarding the request to other.
If you want to show the the jsp page on browser..try using sendRedirect(),it is like "i don't have the functionality..you requested person(browser) directly go to other resource'.
Thanks.


The value of an idea lies in the usage of it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getRequestDispatcher problem
 
Similar Threads
How container recognizes a request for servlet
doubt in forwarding
servlet URL question
Hello World
getRequestDispatcher forwarding across applications