向 Hello World JSP 页面添加参数

Adding Parameters to Hello World JSP page

我是新手,所以我确定有一个简单的解决方案,但我要回答的问题是 "This page should display a simple hello world message. In addition, your JSP page should look for a parameter in the request (GET) named “user”. If the user parameter is present, it should read the name from the request and display a greeting to the user. If the parameter is not present, it should display a generic “Hello World” message"

到目前为止我得到的是:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World - JSP tutorial</title>
</head>
<body>
    <%= "Hello World!" %>
</body>
</html>

我将如何添加参数?

开始了:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World - JSP tutorial</title>
</head>
<body>
<%
   String user = request.getParameter("user");
   response.getWriter().println(user == null ? ("Hello World") : ("Hello World " + user)); 
%>
</body>
</html>