PRJ301_-_2_-_SP_2024_-_FE_1718.webp
Todoroki_87

PRJ301_-_2_-_SP_2024_-_FE_1718.webp

(Choose 1 answer)
Following is the code for doGet() and doPost() methods of TestServlet.
Which of the statement is correct?
A. It'll throw an exception at runtime, as you cannot call doGet() from doPost().
B. This will work for HTTP GET as well as POST requests.
C. This will only work for HTTP POST requests
}
D. This will only work for HTTP GET requests
E. It'll throw an exception at runtime only if a POST request is sent to it.
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
try
{
PrintWriter pw = res.getWriter();
pw.println("<html><head></head><body>");
String name = req.getParameter("name");
String[] hobbies req.getParameterValues ("hobbies");
pw.println("Hello, "+name+"! <br> As I understand, your hobbies are:");
for(int i=0; i< hobbies.length; i++)pw.println("<br>"+hobbies[i]);
pw.println("</body></html>");
}
catch (Exception e)
{
e.printStackTrace();
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
doGet (req, res);
}

): 43

Thông tin

Category
PRJ301
Thêm bởi
Todoroki_87
Ngày thêm
Lượt xem
2,395
Lượt bình luận
22
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRJ301_-_2_-_SP_2024_-_FE_1718.webp
File size
284.6 KB
Dimensions
1920px x 892px

Share this media

Back
Bên trên Bottom