chunk of code...

public void init(ServletConfig config)
    throws ServletException
	{
		Map map = new HashMap();
	}
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
   [U]map.put("one1","two2");[/U]

compiler says 'map' cannot be resoled......why so?
wht shd i do?

thanks,
BeanBoy

Recommended Answers

All 2 Replies

I would suggest that you stop working on this servlet thing and start learning some basic java because this error is very basic and usually done by beginners.

You declare the Map in one method locally and you try to access it from another method.
Declare it globally or declare another Map in "doGet" depending on what you want.

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.