By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,646 Members | 1,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,646 IT Pros & Developers. It's quick & easy.

How to send parameter to servlet through form

P: 1
I created one email having To,Content ,Images. i will send this email through "SMPT" server.
i get TO,Content ,Images parameters in servlet by
getParameter().
but i will separate image paths through jquery code
like this & i will send to servlet:

Expand|Select|Wrap|Line Numbers
  1. $('#SEND').live('click', function(event){
  2. var s; 
  3. var imgs=" ";
  4. $(".em-mdimage").each(function(){
  5. var i = $(this).find('.mail').attr("src");
  6. console.log(i);
  7. var path = i.split("=");
  8. if(path[1]){
  9. imgs = imgs + path[1] + '~';
  10. console.log(imgs);
  11. }
  12. });
  13. s = imgs;
  14. console.log(s);
  15. $("#emailForm").submit();
  16. });
  17.  
Here "s" having all image paths
This is my HTML code for "email page" :

Expand|Select|Wrap|Line Numbers
  1. <div id="emailTemp" style="display:none" >
  2. <form id="emailForm" enctype="multipart/form-data" method="get" action="http://localhost:8080/weather/servlet.EmailServlet " target="EmailServlet" name="emailForm">
  3. <div class="em-main" style="text-align: center">
  4. <div class="em-div-head" align="center"> E-Shop Jewellery </div>
  5. <div class="em-textbox" style="border:hidden">
  6. <input type="text" value="To:" name="recipients" style="width:97%">
  7. </div>
  8. <div id="em">
  9. <div class="em-middle">
  10. <div style="border-bottom:solid 1px #CCCCCC">
  11. <textarea class="em-textarea" onblur="if (this.value == '') { this.value='Write a message..'; }" onfocus="if(this.value == 'Write a message..') { this.value = ''; }" value="Write a message.." name="content">Write a message..</textarea>
  12. </div>
  13. <div id="em_rt_tp_scroller" class="em_rt_tp_scroller">
  14. <div id="em-rightscrollerimage" style="border:none">
  15. <div class="em-mdimage">
  16. <img class="mail" src=" http://localhost:8080/weather/servlets.ImgDisplayServlet?id=D:\EML\workspace\ass ets\tried-imgs\amala-Paul-amazing-stills-2__1882_IMG_5731_226_283.png " alt="imagecontainer image" style="max-height:100%; max-width:100%;">
  17. <ul>
  18. <img id="em-delete" class="removeicon" width="7" height="7" title="Remove" bottom="10%" src="jqe13/image/delete_s.PNG">
  19. </ul>
  20. </div>
  21. <div class="em-mdimage">
  22. <img class="mail" src=" http://localhost:8080/weather/servlets.ImgDisplayServlet?id=D:\EML\workspace\ass ets\tried-imgs\amala-Paul-amazing-stills-2__1882_IMG_5731_226_279_1930_IMG_5649_222_277.png " alt="imagecontainer image" style="max-height:100%; max-width:100%;">
  23. <ul>
  24. <img id="em-delete" class="removeicon" width="7" height="7" title="Remove" bottom="10%" src="jqe13/image/delete_s.PNG">
  25. </ul>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="em-bottom" align="center">
  31. <input id="SEND" type="button" value="send" name="">
  32. <input id="CANCEL" type="button" value="cancel" name="">
  33. </div>
  34. </div>
  35. </div>
  36. </form>
  37. </div>
  38.  
if i run my servlet i got only To & Content ,but i don't know how to pass "s" to servlet. because images are attached to mail dynamically.
can any one help me how to pass S (s=imgs;) to servlet.
thanks in advance.
Sep 12 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.