File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show text attachment in Servlet

 
jagadish r
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am wokring to displaying data in TEXTAREA of jsp page as text attachment.

No error but attachment showing all jsp page code with textarea data.

I need only textarea data...

Here is my JSP and servelt code

jsp code:-

<form action="/servlet/SaveResponse" method="post">
<td>Response:</td>
<%if((String)session.getAttribute("respMsg")!=null){%>
<td><textarea name="responseMsg" rows="22" cols="75" readonly="readonly"><%=(String)session.getAttribute("respMsg")%></textarea></td>
<%} %>


Servlet Code:

String saveMsg=request.getParameter("responseMsg");
String filename="xyz.txt";
ServletOutputStream outStream = response.getOutputStream();response.setContentType("text/plain");
response.setHeader("Content-disposition","attachment;filename="+filename);
outStream.println(saveMsg);


Regards,
Praveen
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Praveen",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"jagadish r",
Please check your private messages.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic