-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCWE-150.java
More file actions
19 lines (18 loc) · 749 Bytes
/
Copy pathCWE-150.java
File metadata and controls
19 lines (18 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class test extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = request.getParameter("name");
// alow only specific characters like - dot or comma or space or alphanumeric characters if something else then error
if (name.matches("[a-zA-Z0-9.,- ]+")) {
out.println("Hello " + name);
} else {
out.println("You can use only dot comma or space or alphanumeric characters, rest are not allowed");
}
}
}