Problem with setAttribute()
hey i want to send output from servlet file to jsp page as i need to display the count field value for the no of times the site is being visited.
jsp page --->welcome.jsp
sevlet ---->hitCountHandler.java
as soon as the welcome file is loaded , i want to display the 'count' value from servlet in the control 'hitCountField' of jsp page by trying this:-
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String countValue = String.valueOf(++count);//static int count;
RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/welcome.jsp");
request.setAttribute("hitCountField.value", countValue);
requestDispatcher.forward(request,response);
}
prblm1:
but unable to produce the 'count' value from servlet to jsp control 'hitCountField', it shows null.
prblm2:
how to load count value at load time of first jsp page ->welcome.jsp , i mean to ask which control of jsp page would trigger the servlet at load time of jsp page OR please provide any other solution if exists.
waiting for your reply.........:mad: