If you have written it in javascript, well...that always executes on the client side. If you are calculating date through javascript, its too late, that code is gone.
To solve this, you would have to make your js function receive data through parameters, and that data should be calculated on the server side.
You could do something like.
<%@ page import ="java.util.Date" %><%--Imports date --%>
<% Date date = new Date();
String strdate = date.toString();//could be formatted using SimpleDateFormat.
%>
<!--must be inside a form -->
<input type="text" value="javascript:showDate('<%=strdate%>');"/>
<!--must be inside a table-->
<td>javascript:showDate(<%=strdate%>);</td>
Or more elegantly, get server date in your java class, and write it to request:
//formattedDate is defined above, in the format you like the most. Could be a
//java.util.date or a String
request.setDate("date",formattedDate);
And then, in your jsp, using for example, JSTL
<c:out value="${formattedDate}"/>
Or,
<% //this java code is run on the server side.
String strdate = (String)request.getAttribute("date");
%>
<%=strdate%><!-- prints strdate to jsp. Could put it in a table, form, etc -->
EDIT: In response to your comment, you should:
<%--Imports java packages --%>
<%@ page import ="java.util.Date" %>
<%@ page import ="java.text.SimpleDateFormat"%>
<%-- Java code --%>
<% Date date = new Date();
Calendar calendar = Calendar.getInstance(TIME_ZONE).setTime(date);
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");
String strdate = sdf.format(calendar.getTime());
%>
<html>
<body>
<!-- Does not need to use javascript. All work is done on the server side.-->
<table>
<tr>
<td><%=strdate%></td>
</tr>
</table>
</body>
</html>
I have no idea what your time zone is, but I'm sure you do.
Calendar.getInstance() takes an instance of TimeZone as a parameter. That should do it
Take a look:
http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html
http://java.sun.com/javase/6/docs/api/java/util/Calendar.html
Interesting link about JSP