Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with request.setAttribute() in jsp page

807601Jan 15 2008 — edited Jan 15 2008
Hi

I am setting a attribute in jsp page as below.
<Body>
Click on below given Links.
<form name="newform" action="Parse.do" method="post">
<table>
<%
for(int i=0;i<10;i++) {
	Integer i1=new Integer(i);
	request.setAttribute("currValue"+i,i1);%> 
			 <Tr><td><a href="javascript:newform.submit()"><%=i%></a></td></Tr>
		
 <% }%>
</table>
</form>
</Body>
Now after mapping URL from web.xml control is moving towards a servlet :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class MainServlet extends HttpServlet {

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		out.println("Here is your jpg Advice:");
		out.println(((Integer)request.getAttribute("currValue1")).toString());
		
	}
}
BUT it is giving value NULL.

Please help me on this.
Cant' a request attribute be set from JSP and then used from Servlet ?

Thanx in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2008
Added on Jan 15 2008
2 comments
557 views