We have a variable in jsp:
${time} how can i get it in jsp script
<% String t = ${time}; <- вот тут %> Tell me. Thank.
Did so
assigned the value of the time variable in the JSP
<c:set var="time" value='2016.08.10 00:00:00'/> <% // запросили значение String date_input =(pageContext.getAttribute("time", PageContext.PAGE_SCOPE)).toString(); // подготовка формата даты SimpleDateFormat format_data = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); DateFormat format = format_data; Date date = format.parse(time); format_data.applyPattern("dd.MM.yyyy HH:mm:ss"); date_input=format.format(date); %> Are you sure that you really NEED a scriptlet? You definitely can not prepare the data in the bin or before transferring control to the JSP? If it is not exactly 100,500%, then you can get through one of the contexts (depending on where this variable comes from). This will be either the pageContext, or the session, or the application context or the request context, which are available either directly or through the servlet context.
Source: https://ru.stackoverflow.com/questions/8660/
All Articles