Friday 15 February 2013

java - How to call a method and its variable in JSP? -


Trying to display the current date on one page in JSP but getting a strange error code. Any thoughts that I am doing wrong?

  & lt;% date today = new date (); & Gt%; & Lt;%! Public string display date (date date) {return date.toString (); }% & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Title & gt;! Welcome & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; & Lt; Center & gt; Today's date is: & lt;% displayDate (& lt;% = today%>);% & gt; & Lt; / Center & gt; & Lt; / H1>  

this

  & lt;% displayDate ( & Lt;% = today & gt;);%>  

should be something like

  & lt;% = displayDate (today); & Gt%;  

In addition, I recommend you move away from the screenplate.


No comments:

Post a Comment