This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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??
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.
...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...
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.
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.
subject: how to know which servlet/jsp calling a particular servlet