reset password
Author Message
lishenyu
Posts: 103
Posted 19:39 Nov 11, 2014 |

Dr sun ,

could you tell me that ,is the completed a link or a button ?

if it's a link ,where should it go ,a servlet called Completed ? I did this ,but the Completed button only needs to control something ,it doesn't need to show something , so it show an error when go to this"/Completed?index=1' because there is no suck page ,after press Completed we should still show the current tasks page

But if it's a button , both the Add and this Completed should be implemented in the doPost of Currenttasks, ,the doPost doesn't know which button is clicked 

Rinchan7
Posts: 56
Posted 21:25 Nov 11, 2014 |

You can make it a link that goes to a servlet 'Completed', and in doPost, do what you need to have the item register as completed (like say, give it a boolean property completed and then just determine which items are showed in the main page or the completed task page, based on whether they are completed or not), after you have finished changing the item's status, you could have it redirect back to the main page.

I think making Add the only button of the form makes things easier

cysun
Posts: 2935
Posted 22:41 Nov 11, 2014 |

If it's shown as a link in the assignment description, it's a link, though you can use a button and make it work too. Whether it's a link or button is not important.

I said in class that a form processing operation is usually implemented using one servlet where doGet() displays the form and doPost() processes the form submission. Note that not all operations are form processing operations though. For example, for the "Complete" operation, all it needs is the id (or index) of the task, which can be easily embedded in a URL, so there's no need for a form, and you can implement it in doGet() and that's it.

lishenyu
Posts: 103
Posted 22:49 Nov 11, 2014 |
cysun wrote:

If it's shown as a link in the assignment description, it's a link, though you can use a button and make it work too. Whether it's a link or button is not important.

I said in class that a form processing operation is usually implemented using one servlet where doGet() displays the form and doPost() processes the form submission. Note that not all operations are form processing operations though. For example, for the "Complete" operation, all it needs is the id (or index) of the task, which can be easily embedded in a URL, so there's no need for a form, and you can implement it in doGet() and that's it.

o ,in doGet()  of the Completed servlet ,or the CurrentTasks servlet ? Thanks!

cysun
Posts: 2935
Posted 23:57 Nov 11, 2014 |
lishenyu wrote:
cysun wrote:

If it's shown as a link in the assignment description, it's a link, though you can use a button and make it work too. Whether it's a link or button is not important.

I said in class that a form processing operation is usually implemented using one servlet where doGet() displays the form and doPost() processes the form submission. Note that not all operations are form processing operations though. For example, for the "Complete" operation, all it needs is the id (or index) of the task, which can be easily embedded in a URL, so there's no need for a form, and you can implement it in doGet() and that's it.

o ,in doGet()  of the Completed servlet ,or the CurrentTasks servlet ? Thanks!

Completed servlet.

lishenyu
Posts: 103
Posted 20:21 Nov 13, 2014 |
cysun wrote:
lishenyu wrote:
cysun wrote:

If it's shown as a link in the assignment description, it's a link, though you can use a button and make it work too. Whether it's a link or button is not important.

I said in class that a form processing operation is usually implemented using one servlet where doGet() displays the form and doPost() processes the form submission. Note that not all operations are form processing operations though. For example, for the "Complete" operation, all it needs is the id (or index) of the task, which can be easily embedded in a URL, so there's no need for a form, and you can implement it in doGet() and that's it.

o ,in doGet()  of the Completed servlet ,or the CurrentTasks servlet ? Thanks!

Completed servlet.

Dr sun ,can you tell me the difference between request.getAttribute(),request.setAttribute()  and getServletContext.getAttribute(),

getServletContext.setAttribute() ?  and when to them respectively ? Thank you !

cysun
Posts: 2935
Posted 20:47 Nov 13, 2014 |

One saves the object in request scope and the other saves the object in application scope.