• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Setting attributes from JSP to Servlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody help me ??? thanks
JSP code:
...
<%
request.setAttribute("name", "Husam Haddad");
%>
...//forwarding to servlet using the form HTML tag

Servlet code:
{
...
String name = request.getAttribute("name");
System.out.println("name is " + name);
...
}

the output is : name is null

why is null ?
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

forwarding to servlet using the form HTML tag



That is most decidedly not a forward.

When the HTML page is delivered to the browser, the request goes out of scope and with it the request scoped variable.

For some basic understanding of how JSPs work, please read this article.
 
rubbery bacon. rubbery tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic