Reputation: 35
I am working with servlets.I have created a jsp page and it includes some scripts for jquery.Every statements using jquery is working fine when the page is loaded from servlet using response.sendredirect(). as below
response.sendRedirect("./ff/test.jsp");
I have done the same thing by using requestdispatcher.forward() because i need to pass a data to that jsp.
RequestDispatcher rd=request.getRequestDispatcher("./ff/test.jsp");
rd.forward(request, response);
Now it has redirected to correct jsp page and also the data can be accessed inside that page.But the problem is that I am getting reference error "$ is not defined".Is it possible to solve this issue?
Upvotes: 1
Views: 883
Reputation: 13232
Your javascript links should be like <script type="text/javascript" src="<%= request.getContextPath() %>/yourpath/yourfilename.js></script>
. This is just an example. You must specify request.getContextPath() because your context is now the context of the servlet not the jsp so relative path won't work here.
Upvotes: 1