what is the purpose of using logic tags in struts?
i gu开发者_StackOverflowess for checking user input,If it is the case where the checking performed in client side or server side?why we choose this rather than other checking like JS,JSP,java,validate?
Struts is a Java Web Framework, built on top of Servlet/JSP technologies. Therefore, it runs on the server, not on the client. Whereas JavaScript run on client. So, whatever you need to check on server has to go in server-side code.
Struts doesn't recognise JSP EL, and writing Scriptlets in JSP is already a bad idea. So, we end-up using Struts logic tags.
We perform most of the control and business logic in servlet and model classes, respectively. Only the presentation logic should be written using Struts logic tags.
No, most likely the use of Struts logic tags is not for validating user input. We configure validators for that using Struts validators, and for client-side validation we use JavaScript, either provided by Struts or our own.
I hope it answers your question.
The purpose of Struts' logic
tags is to alter output depending on the given criteria. The tags print out their body only if the corresponding comparison evaluates to true.
As an example, to see if some variable is in session:
<logic:present name="someSessionVariable" scope="session">
"found!"
</logic:present>
You may consult Struts Logic Taglib reference for more info.
精彩评论