• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

how to know which servlet/jsp calling a particular servlet

 
Ranch Hand
Posts: 55
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

let me explain what i want to know.....
i am using a website where from the Administrator's page the Administrator can see the employee details(showEmployeeDetails.jsp) and also can update employee details(updEmployeeDetails.jsp).

the updation is done through updEmployeeDetails.java servlet, now if i want to call updEmployeeDetails.java from both showEmployeeDetails.jsp) and updEmployeeDetails.jsp, then is it possible??
is there any way to know which page is calling the servlet??

note::
while seeing details, if the Administrator feels like updating or changing some data, she dont have to go back to the update.jsp page, and then from there calling updEmployeeDetails.jsp to finally update the detail calling updEmployeeDetails.java.
i want to minimize this hazzle.
 
Bartender
Posts: 4101
64
Hibernate Fedora Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

...the updation is done through updEmployeeDetails.java servlet, now if i want to call updEmployeeDetails.java from both showEmployeeDetails.jsp) and updEmployeeDetails.jsp, then is it possible?? is there any way to know which page is calling the servlet??


Servlets are called from the URL patterns defined in web.xml. So if you want the same servlet to be called you should send the request to the correct servlet(using the URL pattern defined) with proper request parameters required to process the request.

Note: If you have done some code that we can see it would be easier to suggest what exactly (and how) should be done...
 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, ok,
here is the code for updEmployeeDetails.jsp

which is calling the following file....

this file is again calling the following servlet...

now, what i am saying is that is it possible to call this servlet from the page where i am checking the employee details?
my web.xml file is this.....


Sooooo many of codes...............................
 
Vijitha Kumara
Bartender
Posts: 4101
64
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all you should avoid writing Java code inside JSPs (at least in new code). And both doGet() and doPost seems to be used to update the table which is not a good idea. Generally HTTP GET request is considered idempotent (i.e.: safe to execute multiple times without any side effects).

In to your code:
According to this code when the first JSP calls the second it needs a form submit in order to display the data which does not happen automatically. So you'll have to change the design accordingly. Use JSPs only as a view component. This way you can avoid most of the confusion in the code. And call your servlet which handles the retrieval of customer data when user submit a query parameter. Then you may display them in a different JSP by forwarding the request from the servlet.

You may read about MVC pattern to get a better idea how this happens...
Also read about the Request Dispatcher on how to dispatch requests....
 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i know that, but still it was a mistake. actually i wanted to display the values on to textboxes directly from the database table, so i coded in the jsp page.
but ok, now i will store the values fetched, into session/context and then display it into the view.
thanks for reminding me.
i will keep it in mind everytime i code.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!