How to send List from jsp to action class
hi,
i m fetching list from database and showing to jsp as follows:
user can update that list i need to collect that updated list in next action class but i m not able to do that. can anybody suggest me any solution the code i m using is as follows:
<html:form action="/myUpdate">
<table>
<tr>
<td>
<label><input type="text" property="name" name="name" value=""/></label>
</td>
</tr>
<logic:iterate id="address" name="info" property="addressList" indexId="rowindex">
<tr>
<td>
<input type="text" value="" name="address[<bean:write name="rowindex"/>].houseno" />
</td>
<td>
<input type="text" value="" name="address[<bean:write name="rowindex"/>].roadname" />
</td>
<td>
<input type="text" value="" name="address[<bean:write name="rowindex"/>].city" />
</td>
<td>
<input type="text" value="" name="address[<bean:write name="rowindex"/>].state" />
</td>
<td>
<input type="text" value="" name="address[<bean:write name="rowindex"/>].country" />
</td>
</tr>
</logic:iterate>
<tr>
<html:submit/>
</tr>
</table>
</html:form>
here in privious action i m settting bean object in session with name 'info'. it is fetching data and disply it correctly but when i m trying to get this updated data in myUpdate action i m not getting list element.
--------------- MyBean.java----------------------
package form;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
* @author Sushant.Raut
public class MyBean extends ActionForm {
Logger log = Logger.getLogger(this.getClass());
/* (non-Javadoc)
* @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
super.reset(mapping, request);
this.name = "";
public String toString()
System.out.println("name : " + this.name );
for(Iterator<Address> iterator = addressList.iterator(); iterator.hasNext();)
Address address = (Address)iterator.next();
System.out.println("city : " + address.getCity());
return null;
private static final long serialVersionUID = 1L;
private String name;
private List<Address> addressList;
* @return the names
public MyBean()
log.info("Bean Construtor is called.");
System.out.println("MyBean:::::constructor is called.");
public String getName() {
log.info("Bean getName() is called");
return name;
* @param names the names to set
public void setName(String name) {
this.name = name;
log.info("Bean setName() is called");
* @return the address
public List<Address> getAddressList() {
log.info("Bean getAddressList() is called");
return addressList;
* @param address the address to set
public void setAddressList(List<Address> address) {
log.info("Bean setAddressList() is called");
this.addressList = address;
public Address getAddress(int index)
log.info("Bean getAddress(int index) is called");
while(index >= addressList.size())
addressList.add(new Address());
return this.addressList.get(index);
public void setAddress(int index, Address address)
log.info("Bean setAddress(int index, Address address)) is called");
this.addressList.add(index, address);
}------------- Address.java------------
package form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
* @author Sushant.Raut
public class Address {
private String houseno;
private String roadname;
private String city;
private String state;
private String country;
public Address(){}
* @return the houseno
public String getHouseno() {
return houseno;
* @param houseno the houseno to set
public void setHouseno(String houseno) {
this.houseno = houseno;
* @return the roadname
public String getRoadname() {
return roadname;
* @param roadname the roadname to set
public void setRoadname(String roadname) {
this.roadname = roadname;
* @return the city
public String getCity() {
return city;
* @param city the city to set
public void setCity(String city) {
this.city = city;
* @return the state
public String getState() {
return state;
* @param state the state to set
public void setState(String state) {
this.state = state;
* @return the country
public String getCountry() {
return country;
* @param country the country to set
public void setCountry(String country) {
this.country = country;
public void reset(ActionMapping mapping, HttpServletRequest request)
this.city = "";
this.country = "";
this.houseno = "";
this.roadname = "";
this.state = "";
}------ MyAction.java------
package action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import form.Address;
import form.MyBean;
* @author Sushant.Raut
public class MyAction extends Action {
Logger log = Logger.getLogger(this.getClass());
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception{
MyBean myBean = new MyBean();
log.info("Bean is Initialised.");
String name = "sushant";
Address address = new Address();
address.setCity("city1");
address.setCountry("India");
address.setHouseno("1111");
address.setRoadname("xyz Road");
address.setState("MH");
Address address1 = new Address();
address1.setCity("Hyderabad");
address1.setCountry("India");
address1.setHouseno("2222");
address1.setRoadname("ABC Road");
address1.setState("AP");
List<Address> addressSet = new ArrayList<Address>();
addressSet.add(address);
addressSet.add(address1);
myBean.setName(name);
myBean.setAddressList(addressSet);
request.getSession().setAttribute("info", myBean);
log.info("Bean is bound to session.");
System.out.println("MyBean object is bound to session.");
System.out.println(myBean);
return mapping.findForward("success");
}-------- show.jsp-----------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<html:form action="/myUpdate">
<table>
<tr>
<td>
<label><html:text property="name" name="info"/></label>
</td>
</tr>
<logic:iterate id="address" name="info" property="addressList" indexId="rowindex">
<tr>
<td>
<html:text property="houseno" name="address" indexed="true"/>
</td>
<td>
<html:text property="roadname" name="address" indexed="true"/>
</td>
<td>
<html:text property="city" name="address" indexed="true"/>
</td>
<td>
<html:text property="state" name="address" indexed="true"/>
</td>
<td>
<html:text property="country" name="address" indexed="true"/>
</td>
</tr>
</logic:iterate>
<tr>
<html:submit title="Submit"/>
</tr>
</table>
</html:form>
</body>
</html>
Similar Messages
-
How to send SMS from JSP application.
Hi,
I have created a web application using JSP for our Office internal use. I want to include the folowing option in our app.
1) How to send SMS from the application to mobile.
2) I don't want to use third party service (ex: SimpleWire). as the app is for internal purpose only.
It will be helpful, if I get the complete procedure to implement it, as this is my first application.
Thanks & Regards
suresh.I am having problem with smslib. smslib is an enhanced version of jsmengine, I have compiled the program, there is no error but when I run it , the following error is found. Can you help? my email is [email protected]
Exception in thread "main" java.lang.NoClassDefFoundError: CIncomingMessage (wrong name: org/smslib/CIn
comingMessage)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) -
how to send sms from jsp
First of all, you need to have the gsm modem or access to any Telco sms gateway.
If you don have any access to the Telco sms gateway, try to download the SMSLib-Java-v2.1.2 java library from the http://sourceforge.net/project/showfiles.php?group_id=164313.
Edit the example in the download file and include the example in your JSP file to send the sms using GSM modem. -
hi,
i want to send mail from my jsp page.
1) how can i do this
2) do i need any mail server for doin this
thanks
regards
manoji want to send mail from my jsp page.
1) how can i do this
2) do i need any mail server for doin thisRead
http://java.sun.com/developer/onlineTraining/JavaMail/
Rather,
try this:
http://jakarta.apache.org/taglibs/doc/mailer-doc/mailer-1.1/index.html -
How can Send Email From JSP to all Mail server.it gives error
I try this code in netbean 5.But it will give the Error.
The code:
<%@page import="java.util.*"%>
<%@page import="javax.mail.*"%>
<%@page import="javax.mail.internet.*"%>
<%
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.gmail.com" );
props.put("mail.smtp.port", "465" );
Session s = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(s);
String From = request.getParameter("sender");
InternetAddress from = new InternetAddress(From);
message.setFrom(from);
String Tos = request.getParameter("reciever");
InternetAddress to = new InternetAddress(Tos);
message.addRecipient(Message.RecipientType.TO, to);
String sub =request.getParameter("subject");
message.setSubject(sub);
String mgs =request.getParameter("message");
message.setText(mgs);
Transport.send(message);
%>
<html>
<p align="center">
A Message has been sent. <br>
Check your inbox.
</p>
<p align="center">
Click here to send another!
</p>
</html>
Error is :
javax.servlet.ServletException: Could not connect to SMTP host: smtp.gmail.com, port: 465
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.MailBeema_jsp._jspService(MailBeema_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
root cause
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
javax.mail.Service.connect(Service.java:275)
javax.mail.Service.connect(Service.java:156)
javax.mail.Service.connect(Service.java:105)
javax.mail.Transport.send0(Transport.java:168)
javax.mail.Transport.send(Transport.java:98)
org.apache.jsp.MailBeema_jsp._jspService(MailBeema_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connectFairly self-explaining, isn't it? That host cannot be connected.
Either check the correctness of the hostname/port, or check your network settings (firewall, router, etc). -
OBIEE 11g: How to send email from Analysis (via Action Framework)
Hi,
I have installed OBIEE 11g SampleAppLite in my POC box.
One of the features I want to have is to allow users to send their feedback (email) about a report to the report owner. Can this be done without launching Outlook? I tried to Invoke a Browser Script and found that I can display a form showing Recipient, Subject and Message text fields, but I do not know how to send the email.
Thanks!Hi Devarasu,
Thanks for your reply. The link you gave is for sending iBots. But if I do this, users will not be able to send their feedback / comment. -
How to log exception from a struts action class
Hi guys,
I am recoding my application to use the strut framework. There's one small thing i wonder is that how i can log an exception arrise in an action class. In my original servlet, wherever an exception arise, i use:
catch(Exception e)
getServletContext().log("User enter an invalid date");
throw e;
}However, when i move this servlet into a action class, the getServletContext method doesnt work anymore. I thought action is a child of httpServlet but since getServletContext is not available in action, then how can i log the error?
Hope to get some help
Message was edited by:
lnthai2002Hi guys,
I am recoding my application to use the strut
framework. There's one small thing i wonder is that
how i can log an exception arrise in an action class.
In my original servlet, wherever an exception arise,
i use:
catch(Exception e)
getServletContext().log("User enter an invalid
valid date");
throw e;
}However, when i move this servlet into a action
class, the getServletContext method doesnt work
anymore. I thought action is a child of httpServlet
but since getServletContext is not available in
action, then how can i log the error?
Hope to get some help
Message was edited by:
lnthai2002Action class is just a POJO and works a handler of your request. ActionServlet invoke your Action class based on the action you call in your URL. When you are usign the Struts why do you need your Original Servel, use the ActionServlet and if required you can extend it and create your own servlet -
How to send info from JSP page as email-body
Hi,
i have a JSP page that generates dynamically as a result of some query. I have a Button - "Send Email".
I want to send the information to the receipient thru email automatically on a button click,
All information is in the memory. How can we pick the info from memory and send it as a message thru email?
Pls help.
thanx & regards,
Shalinicreate a servlet to send mail (use the JavaMail api) then Post the message to the servlet when you click on the button.
OR, put the message and any other data (like the email address) into the session, and then just call the servlet on click of the button, and have the servlet retrieve the information from the session. -
How to send mail from jsp pageq
Pls help me with this topic
Thanks alotCan you make it clearer. Pls give me a sample code if possible
Thanks alot -
I want to send email from jsp,
i want to send email from jsp, i dont know smtp:host, how to send mail?
plz carify this doubt sir.OK thanks sir but i installed alredy. i write this code. plz send any error's are there. and i dont know smtp:host name. i put my port address?
try{
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "//10/0/6/252");
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
msg.setFrom(new InternetAddress("[email protected]"));
msg.addRecipient(Message.RecipientType.To,new InternetAddress("[email protected]"));
// Setting the Subject and Content Type
msg.setSubject("hi..");
msg.setText("hi bharath how are you");
Transport.send(msg);
catch(Exception e)
out.println(e);
} -
Need to Send Mail from JSP...
Dear Team,
I Need to Send Mail from JSP, have Designed user Interface to enter
to, from, subject, and message text .
Have Downloaded mail.jar and activate.jar file..... and placed in tomcat lib directory and WEBAPPS/WEB-INF/lib Directory too
How do i send a mail to user ?
do I require something else apart from things that i have mentioned?
do i have to Configure SMTP, POP3 or Something like this....
Now If I Create a object of Type MimeMessage and Set Recipient, from, subject and if i say transport.send(message) will this do My JOB???Dear Team,
I Need to Send Mail from JSP, have Designed user
Interface to enter
to, from, subject, and message text .
Have Downloaded mail.jar and activate.jar file.....
and placed in tomcat lib directory and
d WEBAPPS/WEB-INF/lib Directory too
How do i send a mail to user ?
do I require something else apart from things that i
have mentioned?
do i have to Configure SMTP, POP3 or Something like
this....
Now If I Create a object of Type MimeMessage and Set
Recipient, from, subject and if i say
transport.send(message) will this do My JOB???Yup! in addition to all the above i need to know my mail box outgoing mail server. and that's enough...... i am able to do that.
Regards,
Jagadeesh HS. -
IDOC :: how to send data from Custom Infotype in SAP HR to third party
Hi,
I have created one custom Infotype by number 9020. How to send data from this infotype to third party system and also change pointers need to trigger for this infotype.
Please help me in doing it.
I am using one Custom Message type ZTALENT and Custom Idoc Type ZTALENT.
ZTALENT Talent Management
5 E1PLOGI Header for an HR Object (Master Data or Organizational Data)
5 E1PITYP HR: Transported Infotypes and Subtypes for an Object
ZPUSER User base Data File
ZPERSON Personal Information File Segment
ZPOST Position File
ZOPE Overall Performance
ZPWORK Outside Work Experience
ZPEDUC Education Details of Employee
E1P0000 HR: HR Master Record Infotype 0000 (Actions)
E1P0001 HR: HR Master Record Infotype 0001 (Org. Assignment)
E1P0002 HR: HR Master Record Infotype 0002 (Personal Data)
E1P0016 HR Master Record: Infotype 0016 (Contract Elements)
E1P0022 HR Master Record: Infotype 0022 (Education)
E1P0023 HR Master Record: Infotype 0023 (Other/Previous Employers)
E1P0041 HR Master Record: Infotype 0041 (Date Specifications)
E1P0105 HR: HR Master Record Infotype 0105 (Communications)
ZE1P9020
ZPLANG Language Details
ZACTION Actions Changes
Regards,
KrishnaHello Shankar,
Technically TEMSE files are read by calling the following 3 function modules in sequence,
1) RSTS_OPEN_RLC or RP_TS_OPEN: open the temse object
2) RSTS_READ : read the object
3) RSTS_CLOSE: close the object
Regards,
Rajesh -
How to send IDocs from a non-SAP system to a SAP system
Hi everyone i am new to SAP R/3 System.
Currently i am required to send IDocs from a non-SAP system to a SAP R/3 System.
There is a guide on Cost-Effective and Quick Communication between SAP and 3rd Party Systems using IDOC HTTP XML Interface. But its from a SAP system to a non-SAP system and i am able to do that.
Is there any step by step guide where they teaches you how to send IDocs from a non-SAP system to SAP system via similar method?
Thank You!Hi,
I hope this link may help you......
http://publib.boulder.ibm.com/infocenter/iisinfsv/v8r1/index.jsp?topic=/com.ibm.swg.im.iis.ds.entpak.sapr3.use.doc/topics/c_pack_r3_Introduction.html -
How to sending email from Oracle Forms
How to sending email from Oracle 6i(Forms)
I need to send email to a distribution list(multiple email addresses).send email of multiple email address
[email protected],[email protected],[email protected]
create or replace function mailout
(sender in varchar2,
recipient in varchar2,
ccrecipient in varchar2,
subject in varchar2,
message in varchar2) return number
is
crlf varchar2(2) := chr(13)||chr(10);
connection utl_smtp.connection;
mailhost varchar2(50) := 'Add email server Ip Address here';
header varchar2(4000);
v_num number :=1;
str number:=0;
email varchar2(50);
begin
connection := utl_smtp.open_connection(mailhost,25);
header := 'Date: '||to_char(sysdate,'dd mon yy hh24:mi:ss')||crlf||
'From: '||sender||' '||crlf||
'Subject: '||subject||crlf||
'To: '||recipient||crlf||
'Cc: '||ccrecipient||crlf||message;
utl_smtp.helo(connection,mailhost);
utl_smtp.mail(connection,sender);
utl_smtp.rcpt(connection,recipient);
while (instr(ccrecipient,',',1,v_num)>0) loop
email:=substr(ccrecipient,str+1,instr(ccrecipient,',',1,v_num)-str-1);
dbms_output.put_line(email);
utl_smtp.rcpt(connection,email);
str:=instr(ccrecipient,',',1,v_num);
v_num:=v_num+1;
end loop;
utl_smtp.open_data(connection);
-- utl_smtp.write_data(connection,header);
utl_smtp.write_data(connection,'MIME-Version:1.0'||crlf||'Content-type:text/html'||crlf||header);
utl_smtp.close_data(connection);
utl_smtp.quit(connection);
return 0;
exception
when utl_smtp.invalid_operation then
dbms_output.put_line('Invalid Operation in SMTP transaction');
return 1;
when utl_smtp.transient_error then
dbms_output.put_line('Temporary problem with sending email ');
return 2;
when utl_smtp.permanent_error then
dbms_output.put_line('Permanent problem with sending email ');
return 3;
end; -
How to genarate javascript from jsp?
how to genarate javascript from jsp?
Edited by: coolsayan.2009 on May 12, 2009 6:21 AMcoolsayan.2009 wrote:
[got an example|http://www.ibm.com/developerworks/web/library/wa-aj-simplejava1/index.html] but can you say all this specifically because i am not familier with AJAX.and i want to generate a javascript random number and by jsp i want to send it to user email.once user got the number it will be checked wheather he got it or not in next page say check.jsp if it this entry is right he will be grant to access the his account....
What does AJAX have to do with the rest of this question? And why do you want to generate a number in JavaScript at all? If you are trying to confirm a working email address, which is what I think you are trying to do then leave that all on the server side. Generate the number in the servlet, mail it, etc. Neither JavaScript nor AJAX are any part of that.
Maybe you are looking for
-
Skype 7.4 crashes on Windows 7/HP laptop
It seems that there is still problems with the HP Web cam and Skype. Similar phenomenon has been reported with earlier Skype verions, but still no official fix. Anyways blue screen appears once Skype starts for the first time right after installation
-
I have a number of books stored in iPhoto, most of which contain pages of text in PDF. When I open the books, wherever I have placed the PDF pages...they are gone. The photo pages are still there, it's just the PDFs. THose pages in the book are bl
-
can anyone tell me in simple terms that acutally work how to cancel my purchase of extra icloud space.
-
Urgent: Xcelsius and BO 6.5 connectivity options
Hi all, I have a requirement in which the users want a Xcelsius 2008 dashboard, but they want the dashboard to connect to BO 6.5. Here is the story, so we have a report in DeskI and that report contains all the data for the dashboard. The users want
-
Authorization/Deauthorization Questions
Mine is a story of woe & bad computer luck. I have gone through several desktop/laptop computers in a relatively short time and have installed iTunes on each of these units. Some of these are no longer accessible to me due to issues of harddrive fail