• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

would u like to open the file or save it to your system

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I am writing a one jsp which consits of textfield,textarea,combobox etc..which is calling a servelt..as request ..is processing ...file download ..window is opening..why this is coming...i want to know..so that ..i can use it.in other case ...where i can save a file ...to my system..in attachment programme..please help me out..

Thanks Friends...


jsp



<html>

<head>
<title> This is a sample Programme </title>
</head>
<form name = "JustFormJsp" method="post" action="/venkat/servlet/JustFormServlet">
<body bgcolor="honeyDew">

<table align="center" >
<tr>
Name:<input type=text name="userName" value="">
</tr>
<tr>
Password:<input type=password name=password value="">
</tr>

<tr>
Sex: <input type=radio name="sex" value="Male" checked> Male
<input type=radio name="sex" value="Female"> Female
</tr>
<tr>
Age: <select name="age"><option>0-10<option>11-20<option>21-30<option>31-40<option>41-50
</tr>
<tr>
Education:<input type="checkbox" name="inter" value="Inter">Inter
<input type="checkbox" name="graduate" value="Graduate">Graduate
<input type="checkbox" name="postgraduate" value="PostGraduate">PostGraduate
</tr>
<tr>
Hobbies:<select name="hobbies" size="3" multiple>
<option>Swimming<option>Tennis<option>Hockey<option>Cricket<option>Chess<option>Kabadi<option>Table Tennis
</tr>
<tr>
Extra Activities: <textArea name="extras" rows="10" cols="50" bgcolor="cyan"></textarea>
</tr>


<tr align="center" >
<input type="submit" name="submit" value="Submit">
<input type="reset" name="refresh" value="Refresh">
</tr>
</table>

</body>
</form>
</html>




Servlet




import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class JustFormServlet extends HttpServlet
{


public void service( HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("html/text");
PrintWriter pw = response.getWriter();

String name = request.getParameter("userName");
String password = request.getParameter("password");
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String inter = request.getParameter("inter");
String graduate = request.getParameter("graduate");
String postgraduate = request.getParameter("postgraduate");
String hobies = request.getParameter("hobbies");
String area = request.getParameter("extras");

String[] hobbies = request.getParameterValues("hobbies");

int serverport = request.getServerPort( );
//int localport = request.getLocalPort();

pw.println("ur name is "+name+" and ur pass word is "+password+" and ur "+sex+" ur education is "+inter+" "+graduate +" "+postgraduate+" and ur age is between "+age+" and about u " + area);

//System.out.println("ur server port number is "+serverport);
System.out.println("ur hobbies are ");
for(int i=0; i <(hobbies.length);i++){
System.out.println(hobbies[i]);
}


}
}
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

response.setContentType("html/text");


should be response.setContentType("text/html");
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Q very much...
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello MR.LYNETTE DAWSON...Thanks for ur reply ...please help me in this case also..Thanks in Advance


One more doubt ..i am wrinting a code..for just view an image ..as

response.setContentType("image/jpeg");

it is working well...but i want not only just to view..but also want an option to save ..to the system..in order to get it..what should i do..

i tried with response.setContentType("html/image");
and also with response.setContentType("html/image/jpeg");

it should showing download wizard...but saving some jsp page...with some data ..which is not understandable....please help me out...what should i do..
 
reply
    Bookmark Topic Watch Topic
  • New Topic