Hi friends I am getting compile time error while compiling this following code. It says 1."No method found matching getHeaders(String) 2."Cannot parse initializer Enumeration values = req.getHeaders(name) import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class HeaderSnoop extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ res.setContentType("text/plain"); PrintWriter out = res.getWriter(); out.println("Request Headers"); out.println(); Enumeration names = req.getHeaderNames(); while(names.hasMoreElements()){ String name = (String)names.nextElement(); Enumeration values = req.getHeaders(name); if(values != null){ while (values.hasMoreElements()){ String value = (String)values.nextElement(); out.println(name + ": " + value); } } } } }
Can some one enlighten me in this matter!. Thanks in advance Nasser
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
Originally posted by Nasser Aboobaker: Hi friends I am getting compile time error while compiling this following code. It says 1."No method found matching getHeaders(String) 2."Cannot parse initializer Enumeration valuesCan some one enlighten me in this matter!
Maybe you have a v2.1 servlet container? I think this method was only introduced in v2.2 of the API. - Peter
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
You are correct peter, this method was introduced with version 2.2. Version 2.1 has a getHeader method.
Bosun
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Nasser Aboobaker
Ranch Hand
Joined: Dec 06, 2000
Posts: 104
posted
0
Hi Peter, Bosun, thanks for your reply. Can you advice me where to get latest servlet container and how to change the current one I am having. I have Tomcat 3.2 installed and working. Is that an old version?. Thanks for your time and help. Nasser
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.