Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to replace this scriptlets from EL in my jsp?  RSS feed

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, how to replace this scriptlets from EL in my jsp??



1. <%
2. Format formatter = new SimpleDateFormat("dd-MMM-yyyy");
3. Date date = new Date();
4. String date1 = formatter.format(date);
5.
6. EditorDao edao = new EditorDao();
7. int x = edao.loadID();
8. %>
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
You should move the java code out from the JSP completely, EL should only be used for displaying and simple logic.
So you would have the java code in your servlet and add the variable to the request:


Then in your jsp you can use EL to display:

Sean
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do just like Sean Clark said.

Work with your code in the servlet then you just access it in the JSP with EL or JSTL.
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the date formatting bit, I would use the JSTL format date tag.





There is no easy/direct way to translate the line: int x = edao.loadID();
That one is probably best done in a servlet/bean.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!