how can add new line character into ajax response for java

how can add new line character into ajax response for java

i want to populated brand drop-down list and state drop-down list by changing on country drop-down list i mean according to country name there will be change in state names groups and brand name groups too... meaning that change in a single drop-down list changes into two dropdown list i hv donw this but i want both drop down will be in a new line how can i do this i m showing my codes here please help me

country.jsp

<%@page import="java.sql.*"%>

<html>
      <head> <br />
      <script language="javascript" type="text/javascript"> <br />
                          var xmlHttp <br />
                          var xmlHttp
                          function showState(str)
                              {
                                  xmlHttp=GetXmlHttpObject();
                                  if(xmlHttp==null)
                                      {
                                       alert ("Browser does not support HTTP Request")
                                       return
                                      }</p>

                             var url="State.jsp";
                              url +="?count=" +str;

                              xmlHttp.onreadystatechange = stateChange;
                                xmlHttp.open("GET", url, true);
                              xmlHttp.send(null);
                         }
                     function stateChange()
                            {   
                              if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
                                  {   
                                    document.getElementById("state").innerHTML=xmlHttp.responseText


                                  }   
                           }
                     function GetXmlHttpObject()
                         {
                                 var xmlHttp=null;
                                 try
                                 {
                                     xmlHttp=new XMLHttpRequest();
                                 }
                                 catch(e)
                                 {
                                     //Internet Explorer
                                     try
                                      {
                                            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                                      }
                                     catch (e)
                                      {
                                            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                                      }
                                }
                            return xmlHttp;
                        }
        &lt;/script&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
 &lt;form action="StateSub.jsp" &gt;
  &lt;select name='country' onchange="showState(this.value)"&gt;  
        &lt;option value="none"&gt;Select Country&lt;/option&gt;  
&lt;%
             String id="";
             String name= "";
             Class.forName("com.mysql.jdbc.Driver").newInstance();  
             Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");  
             Statement stmt = con.createStatement();  
             ResultSet rs = stmt.executeQuery("Select * from country");
             while(rs.next())
             {
             id=rs.getString(1);
             name=rs.getString(2);
 %&gt;
                &lt;option value="&lt;%=id%&gt;"&gt;&lt;%=name%&gt;&lt;/option&gt;  
  &lt;%
            }

 %&gt;
  &lt;/select&gt;  

  &lt;br&gt;  
  &lt;div id='state'&gt;  
  Enter state
  &lt;select name='state' &gt;  
  &lt;option value='-1'&gt;&lt;/option&gt;  
  &lt;/select&gt;  

  Enter brand
   &lt;select name='brand' &gt;  
  &lt;option value='-1'&gt;&lt;/option&gt;  
  &lt;/select&gt;  
  &lt;/div&gt; 


  &lt;input type="submit"/&gt;

  &lt;/form&gt;
  &lt;/body&gt; 
  &lt;/html&gt;

state.jsp

&lt;%@page import="java.sql.*"%&gt;

 &lt;%
String country=request.getParameter("count"); 
 System.out.println("State"+country);
 String buffer="Enter state<select name='state' ><option value='-1'>Select  state</option>"; <br />
 try
  {
         String sid="";
         String snam="";
          String bid="";
         String bnam="";

Class.forName("com.mysql.jdbc.Driver").newInstance();  
     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");  
     Statement stmt = con.createStatement();  
     ResultSet rs = stmt.executeQuery("Select * from state where countryid='"+country+"' ");  
       while(rs.next())
       {
            sid=rs.getString(1);
            snam= rs.getString(3);
            buffer=buffer+"&lt;option value='"+sid+"'&gt;"+snam+"&lt;/option&gt;";  
       }  
     buffer=buffer+"&lt;/select&gt;";

 String buffer1="Enter brand<select name='brand' ><option value='-1'>Select  brand</option>"; 

    Statement stmt1 = con.createStatement();  
     ResultSet rs1= stmt1.executeQuery("Select * from try where countryid='"+country+"' ");  
       while(rs1.next())
       {
            bid=rs1.getString(2);
            bnam= rs1.getString(1);
            buffer1=buffer1+"&lt;option value='"+bid+"'&gt;"+bnam+"&lt;/option&gt;";  
       }  
     buffer1=buffer1+"&lt;/select&gt;"; 
      response.getWriter().print(buffer+"::\\\\n"+buffer1);

  }
 catch(Exception e)
  {
     System.out.println(e);
  }

%>

StateSub.jsp

&lt;%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%&gt;
&lt;%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="&lt;%=basePath%>">

&lt;title&gt;My JSP 'StateSub.jsp' starting page&lt;/title&gt;

&lt;meta http-equiv="pragma" content="no-cache"&gt;
&lt;meta http-equiv="cache-control" content="no-cache"&gt;
&lt;meta http-equiv="expires" content="0"&gt;    
&lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;
&lt;meta http-equiv="description" content="This is my page"&gt;
&lt;!--
&lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;
--&gt;
View Answers









Related Tutorials/Questions & Answers:
how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want... down will be in a new line how can i do this i m showing my codes here please... { xmlHttp=new XMLHttpRequest
how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want... down will be in a new line how can i do this i m showing my codes here please... { xmlHttp=new
Advertisements
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I...;ZHTYPE (Just Logical) Please tell me how can i see this output? Code... This output with this code is true but I want add ZHTYPE at the end of each line
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I...;ZHTYPE (Just Logical) Please tell me how can i see this output? Code... with this code is true but I want add ZHTYPE at the end of each line + XTSM/XTS please
How to insert new line after every space in java
How to insert new line after every space in java  Hii Sir, I have a string with values 69 17 17 16 2 1 1 26 26 56 like this .Now as per my need i have to put all these values into new lines on getting space
How to write file text In New Line
text in new line in Java program. How to write the syntax for this with example... text in a new line. For finds examples or syntax please visit the link How to write file text in New line in Java
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
add new package java
add new package java  How to add new package in Java
Java file new line
Java file new line In this section, you will learn how to write the text in new line of text file. Description of code: The package java.io.* has provide..._TO_REPLACE_1 You can see in the given example, we have created an object
AJAX Line
AJAX Line       AJAX Community with a blog, forum and tutorials Read full DescriptionADS_TO_REPLACE_1
simple ajax Request and Response code...
simple ajax Request and Response code...  var request=null; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } if(request
How can i read a file from nth line onwards in java
How can i read a file from nth line onwards in java  Hi, I need to read a file content from its nth line onwards till end. How can i implement it in java. Regards, Chinnu
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show the japanese character on frame and need to get the japanese string from
How to read big file line by line in java?
Learn how to write a program in java for reading big text file line by line In this tutorial I will explain you how you can read big file line by line... legacy data and add it to your new database system. Example discussed here
how to print a new line after a certain number of prints
how to print a new line after a certain number of prints  How do I make this program print the inputs the user gives 5 per line? So in other words I want the program to print 5 input numbers per line. this is my code so far
How to Delete a column and Add a new column to database
How to Delete a column and Add a new column to database   How to Delete a column and Add a new column to database   Hi, The following... a column in a table- alter table [table name] add column [new column name] varchar
How to add a new item to a dictionary in Python
How to add a new item to a dictionary in Python  Hi, I have an existing dictionary in Python. I want to add new item to it. How to add a new item... to add publication date to this dictionary then you can use following code
Write Text To File In New Line.
Write Text To File In New Line. In this tutorial you will learn how to write text into file in a new line. When you are writing in a file you may be required to finish the line and want to write the other text in a new line
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records
Java - How to read a string line per line
Java - How to read a string line per line  Java - How to read... to read the big String line per line? Is there any API available in Java... it line by line. This way you can reduce the memory usage of the application
How to write file by line in Java
in a new line. How to use Write To File By Line in Java programs...How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
How to add google page in my webpage using jquery ajax.
How to add google page in my webpage using jquery ajax.  Hi, I... not open on my browser. how google page will load using ajax. thanks...://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text
How to add new class in Pkg using the feature of existing class - Java Beginners
How to add new class in Pkg using the feature of existing class   Hi Friends, I want to know , is it possible to add new class in a user Defined... access Variables or methods. Can i use them in another Class in the Same Pkg
How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.
with wsdl format. As i'm new in development. How i can integrate our website...How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.  We have a e-commerce website in ASP.net, c
how can i use ajax and jquery in netbeans ide
how can i use ajax and jquery in netbeans ide  i am using .net here we hav to download ajax controls and if i use netbeans ide and uses ajax control so from where i can get these controls.also i want to know which struct book i
How can you add elements of two arrayLists in java?
How can you add elements of two arrayLists in java?  if you have an arrayList of tempArr = [hi, my, name, is, john] and another arrayList..., is d, john e] how do you go about
How to display string or character
How to display string or character  how to print character or a word without using array concept
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out??  Hi friend, To remove a character in what way : At a specified position
How can I execute a PHP script using command line?
How can I execute a PHP script using command line?  How can I execute a PHP script using command line
How can i display the distance of a line drawing randomly?
How can i display the distance of a line drawing randomly?  How can i display the distance of a line drawing randomly
how can i draw line between two panel contaning circle and line between their center?
how can i draw line between two panel contaning circle and line between their center?   how can i draw line between two panel contaning circle and line between their center
ajax in java - Ajax
ajax in java  Dear deepak sir, My page contain several control... will come "Caseno exist" Sir I am using Ajax first-time.Please help me.   Hi friend, Ajax : Asynchronous JavaScript and XML or Ajax for short
how to read file line by line using filereader in java
how to read file line by line using filereader in java  Hi, how to read file line by line using filereader in java? Thanks   Hi..."; try (BufferedReader br = new BufferedReader(new FileReader(fileName
How to read a large text file line by line in java?
How to read a large text file line by line in java?  I have been... you kind advice and let's know how to read a large text file line by line in java... of the application and the memory available for the Java program. For Java program max
How to Read file line by line in Java program
by line in Java. But there are various ways that can help read a larger file... having less amount of memory. In the example of Java Read line by line below... a complete line and return string line. The other methods that can be used are:ADS
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
Java Servlet : Http Response Headers
Java Servlet : Http Response Headers In this tutorial, you will learn how to Http Response Headers works in java servlet. Http Response Headers : Web... content. You can use HTTP response headers to specify cookies, to instruct
Java Read File Line by Line - Java Tutorial
_TO_REPLACE_1 Developers can also add the further processing logic to process the data line... can also view the detailed tutorial of reading file line by line in Java... how to read a text file in Java one line at a time: Video Tutorial
Java get middle character
Java get middle character In this tutorial, you will learn how to get middle character from the word. Here is an example of getting the middle letter...' and you want to get the character 'p' from the word, then you can
How to make a new List in Java
How to make a new List in Java  Hi, I have to create list object in Java. How to make a new List in Java? Thanks (adsbygoogle... the new operator as shown below: List list = new ArrayList(); Thanks
How Investing Resources Into New Programming Languages Can Impact Businesses?
Programming Languages for Business: How Investing Resources Into New... throughout the company. Yet, how can your company deliver on such expectations without.... By investing resources in new programming languages, your company can wrap your heads
character counter - Java Beginners
character counter  how to show only first three characters...{ BufferedReader in2=new BufferedReader(new InputStreamReader(System.in)); String...!!"); } else{ System.out.println("First Three Character is:"+c[0]+c[1]+c[2

Ads