Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to replace this scriptlets from EL in my jsp?

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working in a mvc architecture, and i have included the following code in my jsp page

<%
Format formatter = new SimpleDateFormat("dd-MMM-yyyy");
Date date = new Date();
String date1 = formatter.format(date);

EditorDao edao = new EditorDao();
long l = edao.loadID();

%>
Since jsp+java code= bad,
So, how to replace this scriptlets from EL in my jsp??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date formatting is handled by the JSTL <fmt:formatDate> tag. Dealing with DAOs is something the controller, not the JSP, should be doing.

It's not always possible to simply take scriptlets that are performing inappropriate actions in the JSP and turn it into corresponding JSTL/EL. Frequently, the JSP must be refactored to remove the actions that should not be performed in the JSP and move them into controllers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic