This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I have two diffrent Servlets that call the same JSP. Depending on which Servlet called the JSP I want to do diffrent logic for each but the JSP is 95% the same. Is there a way to find out which Servlet called it, or is it better just to keep it simple and pass a diffrent parm from each Servlet and intergate it ? Simple Question but I want to use best practice, Thanks
It's better for the servlets to set things up so that the JSPs can just output data. That's a general rule and not just an answer to this specific question.
I don't know what you mean by "pass a different parm" but then I also don't know what you mean when you say the servlets "call" a JSP. If the servlets are forwarding to the JSP then they should just set some request attributes which the JSP will look at. If you meant something else it would help if you clarified that using standard terminology.
Paul, Thanks you answered my question. I will set the request attributes and intergate those. I have a MainFrame background so Parms and Calls are still in my head. I should have said set attributes and forward to JSP.
Think of it like a Java method. If someone were to ask "My method needs to to do something a little different when called from different locations. How can I find out with method called me so I can switch on that?", I'm sure every one would immediately say "Are you nuts? Just pass a parameter that you use to make your decision!"
Also think in terms of the strong versus weak coupling. Which approach is more versatile? Less fragile? More easily understood?