This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Show text attachment in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Show text attachment in Servlet" Watch "Show text attachment in Servlet" New topic
Author

Show text attachment in Servlet

jagadish r
Greenhorn

Joined: Aug 29, 2007
Posts: 7
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

Joined: Mar 06, 2001
Posts: 13459

"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

Joined: Dec 11, 2004
Posts: 13410

"jagadish r",
Please check your private messages.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
Don't get me started about those stupid light bulbs.
 
subject: Show text attachment in Servlet