| Author |
How to arraylist value pass servlet action to JSP file
|
Arjun Palanichamy
Ranch Hand
Joined: Jul 15, 2006
Posts: 51
|
|
Hi.. I have some list of email in array list in servlet action file i want to send and print jsp input textarea box. here paste my servlet action class code : package addressbook; import java.io.IOException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import weebersexception.SearchException; public class MailAddressAction extends HttpServlet { private static final Logger log = Logger.getLogger(MailAddressAction.class); ArrayList contactlist; public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { MailAddressImporter mailaddress = new MailAddressImporter(); try { log.info("Enter the addressbook action page"); contactlist = mailaddress.mail(req); log.info(contactlist); req.setAttribute("contact_details", contactlist); forward("/classifieds/mailaddress.jsp",req,res); } catch (SearchException e) { log.info(e.getMessage()); req.setAttribute("iserror", "yes"); req.setAttribute("errors", e.getMessage()); forward("/classifieds/mailaddress.jsp",req,res); } } public String forward(String url, HttpServletRequest req, HttpServletResponse res) { RequestDispatcher dis = req.getRequestDispatcher(url); try { dis.forward(req, res); } catch (ServletException e) { log.error(e); } catch (IOException e) { log.error(e); } return url; } } ******************************************** please any can help solve this problem. advance thanks. Arjun
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information. You can go back and change your post to add code tags by clicking the .
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
|
What's the problem?
|
 |
Sidharth Pallai
Ranch Hand
Joined: Apr 21, 2008
Posts: 134
|
|
Originally posted by Arjun Palanichamy: Hi.. I have some list of email in array list in servlet action file i want to send and print jsp input textarea box. here paste my servlet action class code : package addressbook; import java.io.IOException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import weebersexception.SearchException; public class MailAddressAction extends HttpServlet { private static final Logger log = Logger.getLogger(MailAddressAction.class); ArrayList contactlist; public void service( HttpServletRequest req, HttpServletResponse res) throws IOException { MailAddressImporter mailaddress = new MailAddressImporter(); try { log.info("Enter the addressbook action page"); contactlist = mailaddress.mail(req); log.info(contactlist); req.setAttribute("contact_details", contactlist); forward("/classifieds/mailaddress.jsp",req,res); } catch ( SearchException e) { log.info(e.getMessage()); req.setAttribute("iserror", "yes"); req.setAttribute("errors", e.getMessage()); forward("/classifieds/mailaddress.jsp",req,res); } } public String forward(String url, HttpServletRequest req, HttpServletResponse res) { RequestDispatcher dis = req.getRequestDispatcher(url); try { dis.forward(req, res); } catch ( ServletException e) { log.error(e); } catch ( IOException e) { log.error(e); } return url; } } ******************************************** please any can help solve this problem. advance thanks. Arjun
.........You can make use of getAttribute() of request to get the value of arraylist and iterate it displaying values inside a scriplet or use JSTL - <c:forEach> to iterate and <c ut> to display each element in jsp.
|
Thanks & Regards
Sidharth Pallai
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: How to arraylist value pass servlet action to JSP file
|
|
|