Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

getRequestDispatcher problem

Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
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
Posts: 67300
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chaitanya,
The forward(..) method will forwards the request on behalf of the main servlet.
It is like 'i don't have the 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 requested person(browser) directly go to other resource'.
Do not threaten THIS beaver! Not even with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!