You mention "Java" in the title of your post. Within the content of the post you don't mention any server side technologies or client side for that matter (other than HTML I mean). So unless I make some assumptions here is what you need.
// index.jsp?var1=peanuts&var2=butter
PHP Code:
<%
String var1 = request.getParameter("var1");
String var2 = request.getParameter("var2");
if(var1 != null && !var1.equals(""))
{
out.println("Var1 has the value: " + var1); // Prints: peanuts
}
if(var2 != null && !var2.equals(""))
{
out.println("Var2 has the value: " + var2); // Prints: butter
}
%>
I'm going to make the assumption that you meant Javascript rather than Java, as they are two completely different languages. A Javascript example can be found here. I don't do Javascript myself.
Here's a PHP example too in case your interested.
// index.php?var1=peanuts&var2=butter
PHP Code:
<?php
$var1 = $_GET['var1'];
$var2 = $_GET['var2'];
if($var1 != null && $var1 != "")
{
echo 'Var1 has the value: ' . $var1; // Prints: peanuts
}
if($var2 != null && $var2 != "")
{
echo 'Var2 has the value: ' . $var2; // Prints: butter
}
?>