Hi Guys I have problem in compiling my jsp page at following code : <%! int i; String s1; <%s1=request.getParameter("t1"); i=Integer.parseInt(s1); %> I got Error as cannot resolve symbol 'request'. Please help me out
Sorry that i missed while coping But my problem still not solved after writing this code: <%! int i; String s1;%> <%s1=request.getParameter("t1"); i=Integer.parseInt(s1); %> I got Error as cannot resolve symbol 'request'. Please help me out
Well I consider Ben and Varun Suggestion , My errors are reduced but i still have error as : C:\jws\tmpdir\default\pagecompile\jsp\_OrderMain.java:26: cannot resolve symbol symbol : variable request location: class pagecompile.jsp._OrderMain String s1= request.getParameter("t1");
Now My code is: <%! String s1= request.getParameter("t1");%> <%try {%> <%! int i=Integer.parseInt(s1);%> <% } catch(Exception e) { e.printStackTrace(); } %>
Maybach Smith
Greenhorn
Joined: Dec 22, 2004
Posts: 15
posted
0
JSP declarations do not have access to automatically defined variables like request, response etc. Please go through this http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html for understanding this. Also,check Ben has already pointed that you cannot access request in declaration. Thanks [ January 28, 2005: Message edited by: Maybach Smith ]
Maybach
Nitin Jawarkar
Ranch Hand
Joined: Dec 18, 2004
Posts: 79
posted
0
hello rushikesh,
write your request.getParameter(); method in scriplet <% %>but not in expression <%! %> ok, hope it will work fine.
Thanx.
Cheers<br />Nitin
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
posted
0
don't use global blocks anyway. You're effectively making your int a static variable which I doubt is your intention.
Follow the advice given here countless times already: JSPs are to be used only for displaying data, not for manipulating it.