import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import redis.clients.jedis.*;
public class Welcome extends HttpServlet
{
Jedis jedis;
public void init(ServletConfig sc) throws ServletException
{
Jedis jedis = new Jedis("localhost");
}
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
int count=0;
PrintWriter out=response.getWriter();
jedis.set("k1","123");//This statement is not working
}
public void destroy(){}
}
I have been trying to access keys and it's values in redis using jedis. It works fine with normal java code. but when it comes to servlets it's not working. I can't able to find the reasons. Pls answer me in detail that how can i use jedis.set() in servlets.