Suppose there are 15 links on the homepage of a site and each link creates a new request, how your servlet controller would handle it? (Assuming you are using MVC-2)

Showing Answers 1 - 3 of 3 Answers

rohit jain

  • May 5th, 2006
 

can we do one thing,that for all those 15 links(call them action)we can have different action ids,now on click of those links we will submit a unique action id related to that particular action and in servlet controller we will make different switch cases based on action id(received) from view(jsp,js) and in turn these case statements will comprise of methods that will go for further actions in model layer (delegate,ejbs,dao,etc. and then to DB and a return jouney)

please comment on the answer.

  Was this answer useful?  Yes

Veeren76

  • Aug 16th, 2006
 

I'd rather keep matters simple.Make different actions for each of the links and not use method-name parameter, it has its own problems. like action classes become huge and code gets intermingled.If you foresee that these action classes will have some common code.... we can subclass the actuall action class and then make the common methods available,egmake something like AbstractAction.java class which subclasses Struts-Action class.Then put common methods in the AbstractAction class and use the same as base class for your custom actions.

Amit Saini

  • Dec 12th, 2006
 

we can use the java script to call 15 different different servlet,each link call a function on the onclick event & this function the call the servlet through using web.xml each link call that type of function in servletPrintWriter out = res.getWriter();out.print(??);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions