java - Servlets showing different outputs? -


i using simple servlet code:

        mycon = drivermanager.getconnection(url);           mystmt = mycon.createstatement();         resultset rs;          string course = req.getparameter("course").trim();           out.println(course);///////here problem          string query="select * tbsolvedbanks course_code='"+course+"' ;";         rs=mystmt.executequery(query);           out.println("<banks>");          while(rs.next())         {             out.println("<bank>");             out.println("<number>"+rs.getstring("number")+"</number>");             out.println("<name>"+rs.getstring("name")+"</name>");             out.println("<title>"+rs.getstring("title")+"</title>");             out.println("<description>"+rs.getstring("description")+"</description>");             out.println("<module_tag>"+rs.getstring("module_tag")+"</module_tag>");             out.println("<additional_tags>"+rs.getstring("additional_tags")+"</additional_tags>");             out.println("</bank>");          }         out.println("</banks>");      } 

when running code on jboss server works fine , prints this:

                beme1104                 <banks>                 <bank>                <number>1</number>                <name>firstbank</name>                <title>question bank 1</title>                <description>in file,we discussed basic things including shortnotes          of properties of substances , aproaches</description>                <module_tag>module i</module_tag>                <additional_tags>uses of point,path function,processes,equilibrium,curves</additional_tags>                </bank> 

but when comment line

               out.println(course); 

it prints values without tags this:

"1 firstbank question bank 1 in file,we discussed basic things including shortnotes of properties of substances , aproaches module uses of point,path function,processes,equilibrium,curves" 

i dont know why facing problem while same code runs fine in servlet.please me new servlets?

check page source in browser. you're not setting content-type of response. browser displays first 1 plain text because doesn't start looking html, , tries displays second 1 html, since it's not valid html, doesn't good.

if want have response displayed plain text, add

response.setcontenttype("text/plain"); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -