How would I do that, I tried this code below but I have an error
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
var name = mmName;
<%String mname = "" %>name;<%;
System.out.println("the name of name is: "+mname);
<%String mname = %>name;<%;
<%String mname = ""+%>name;<%;
Coming to your question, this line
<%String mname = %>
is giving you an error because it's expecting a complete statement and so it prompts you to put a semicolon. However if you simply put a semicolon, then because of your assignment operator, it's expecting you to give a value to that variable.
When you do something like this
String mname = ""+
then because of your
+ (String concatenation) operator, it's expecting a second value that it requires in order to perform a concatenation.
I recommend that you should change your approach because the code inside your
<% .. %> tags is running on server, and the code inside your
<script> .. <script> is running when the file is at client's machine. So it simply won't work with your current approach.