Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use servelt output stream in the program  RSS feed

 
Lot of Q ans
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub



/* ServletConfig config = servlet.getServletConfig();
config.getInitParameter("adminEmail");
*/

response.setContentType("text/html");

PrintWriter out = response.getWriter();

/*System.out.println(getServletConfig().getInitParameter("adminEmail")); */

/* ServletOutputStream out = response.getOutputStream();
response.setContentType("text/html");
out.write("")
*/

System.out.println("Inside servlet do post");
out.println("Beer selction advice");
String color = request.getParameter("color");
System.out.println(color);
Logic logicobj = new Logic();
ArrayList<String> beers = logicobj.getModels(color);
request.setAttribute("choosenBeers",beers);

//Forward the view to the JSP page
RequestDispatcher view = request.getRequestDispatcher("Ans.jsp");
view.forward(request,response);
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is very ambiguous. What is it that you wish to do from the servlet ?

The servlet is used as a controller. Ideally, you would want to populate presentation related objects and attach it to the request scope. You can use this to 'present' a 'view' to the user using a JSP

how to use servelt output stream in the program in a text style....using "write"


Streams are meant to write binary data. Not characters
 
Lot of Q ans
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i have created a mvc model this is just one part of that code........and i have succesfully compiled it using print writer but now i want to learn use of outputstream instead of printwriter.......so need a example for that as m getting confused how to write that...so m trying to implement in that code only
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to stream an image on the server back to the client (say a browser).

Please UseRealWords when you post here. English is not everyone's native language. It makes reading the post easier if you use real words.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!