user2532297
user2532297

Reputation: 81

Get date stamp from jsp and set as attribute in servlet

In my servlet, I want to sort a query from my database by its date stamp. I want users to be able to click on the date stamp in a jsp page,

<td><a href="/edit"><c:out value= "${log.properties.date}" /></td>

which directs them to the /retrieve servlet. Is there a way that I can have the servlet store the "${log.properties.date}" date stamp? Thanks.

Upvotes: 0

Views: 406

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279910

Change your anchor to

<a href="/edit?timestamp=<c:out value="${log.properties.date}" />"> ... </a>

Now the timestamp will be available as a String request parameter. From your servlet:

String strTimestamp = request.getParameter("timestamp");

Parse it accordingly.

Upvotes: 2

Related Questions