• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't get parameter in struts when using input type="file"...?

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone:
Can the common html tag and struts tag be used together?I have an example:in jsp
<html:form method="post" action="sendmail.do" enctype="multipart/form-data">
<tr><td>MailTo:</td><td>
<html:text property="mailto"/></td></tr>
<tr><td>MailFrom:</td><td>
<html:text property="mailfrom"/></td></tr>
<tr><td>Subject:</td><td>
<html:text property="title"/></td></tr>
<tr><td>Content:</td><td>
<html:textarea property="content" rows="7" cols="30"/></td></tr><tr><td>
Attach:</td><td>
<input type="file" name="myfile"/></td></tr><tr><td>
<html:submit/><html:reset/>
</td></tr>
</html:form>

In Action,I want to use the code "request.getParameter("myfile")" to get the file real path.But I always get "null".Why "request.getParamter("myfile")" is null although I choose a file in jsp?
Can struts Tag and html Tag be use together?Thks
:roll:
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes; html tags and struts tags do work together but what you have there is quite confusing. If I read it well it seems you are trying to be able to send attachments by mail. I am really not sure that is how to go about it.
At the same time I am only assuming.
Anselm
 
Yashnoo lyo
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Yes.I want to write a javamail application using struts.Add I want the application can attach attachment.So I must get the file path in Action.But I always get "null" if I use the code "request.getParameter("myfile")".
The Action is also a servlet so I think it will work.But it can't,why?
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you still looking for how to get a handle to myFile then copy this and paste on your servlet. I personally tried it and it worked; probably not the best of solutions.
String[] subString = (((BufferedReader)req.getReader()).readLine()).split("=") ;
String myFile=subString[subString.length - 1] ;
out .write(myFile) ; // prints the name of the file as String
[ October 21, 2003: Message edited by: Anselm Paulinus ]
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anselm Paulinus:
If you still looking for how to get a handle to myFile then copy this and paste on your servlet. I personally tried it and it worked; probably not the best of solutions.
String[] subString = (((BufferedReader)request.getReader()).readLine()).split("=") ;
String myFile=subString[subString.length - 1] ;
out .write(myFile) ; // prints the name of the file as String
[ October 21, 2003: Message edited by: Anselm Paulinus ]

 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic