calling one jsp from another jsp page

calling one jsp from another jsp page

need coding for calling one jsp from another jsp including the xml file.Its urgent

View Answers

May 19, 2011 at 5:17 PM

1)form.jsp:

<html>
<form method="post" action="createxml.jsp">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contact"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)createxml.jsp:

<%@page import="java.io.*,org.w3c.dom.*,javax.xml.parsers.*,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stream.*"%>  
  <%!
        public void createXmlTree(Document doc,String name,String address,String contact,String email) throws Exception{
        System.out.println(name);
        Element root = doc.createElement("Employee");
        doc.appendChild(root);

        Element child1 = doc.createElement("Name");
        root.appendChild(child1);

        Text text1 = doc.createTextNode(name);
        child1.appendChild(text1);

        Element child2 = doc.createElement("Address");
        root.appendChild(child2);

        Text text2 = doc.createTextNode(address);
        child2.appendChild(text2);

        Element child3 = doc.createElement("ContactNo");
        root.appendChild(child3);

        Text text3 = doc.createTextNode(contact);
        child3.appendChild(text3);

        Element child4 = doc.createElement("Email");
        root.appendChild(child4);

        Text text4 = doc.createTextNode(email);
        child4.appendChild(text4);

        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();

        transformer.setOutputProperty(OutputKeys.INDENT, "yes");

        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        DOMSource source = new DOMSource(doc);
        transformer.transform(source, result);
        String xmlString = sw.toString();

        File file = new File("c:/new.xml");
        FileWriter fw=new FileWriter(file,true);
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(xmlString);
        bw.flush();
        bw.close();
      }
      %>
<%
      String name=request.getParameter("name");
      String address=request.getParameter("address");
      String contact=request.getParameter("contact");
      String email=request.getParameter("email");
  try{
      System.out.println(name);
      DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
      Document doc = docBuilder.newDocument();
      createXmlTree(doc,name,address,contact,email);
      out.println("<b>Xml File Created Successfully</b>");
  }
  catch(Exception e){
    System.out.println(e);
  }     
  %>









Related Tutorials/Questions & Answers:
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
Advertisements
calling one jsp from another jsp - JSP-Servlet
calling one jsp from another jsp  Hi All, In my web application... in two.jsp by using jsp declarative tag. Now from one.jsp file I want to call... pageContext.include("./nextjsppage.jsp"); when you use this statement the jsp page
Calling a jsp page from Servlet
Calling a jsp page from Servlet  How can I do this? Suppose I have jsp page aaa.jsp. From aaa.jsp on form action I have made a call to a servlet... List and data is being retrieve. Now I want to pass this List to another jsp page
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi! This is Prasad Jandrajupalli. I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP. I want forward the control from first jsp to second
retrieving of data from one jsp to another jsp - JSP-Servlet
retrieving of data from one jsp to another jsp  using jsp i m displaying a table ,in table i m displaying a radio button then values like id,name etc... that is used for different jsp please help me sir... thanks in advance   Hi
calling servlet from jsp
calling servlet from jsp  how to call a servlet from jsp
Loading a jsp page (with record from database) from another jsp page
Loading a jsp page (with record from database) from another jsp page  Suppose I have two jsp pages Search.jsp and Getdata.jsp. There are two fields... with records from database(against Serial no and year).That is, as soon
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp  <%@ page language="java" import="java.util.*;"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
Calling from JSP
Calling from JSP  how can we call a class file from JSP   Hi, Do you want to call a servlet or a Java Bean through JSP? Please clarify this. For more information, visit the following link: JSP Tutorials Thanks
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  ... a .jsp( say abc.jsp) file which contains multiple Action form.I am required to add one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
how to pass arraylist data from one jsp to another jsp - JSP-Servlet
how to pass arraylist data from one jsp to another jsp  hi to all iam... the following >XXX/ ? is required to send a value from one jsp to another... to receive all employee id's that are retrived from the database in the first jsp
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>"> common.jsp <%String attr=request.getAttribute("param"); out.print(attr
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>"> common.jsp <%String attr=request.getAttribute("param"); out.print(attr
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title and data and each column has 10 enteries. I have a jsp page on which i want
how to change password into one jsp to another jsp
how to change password into one jsp to another jsp  i have two jsps in one jsp i give one password and confirm password, in another jsp i want change my password compare with 1st jsp how to write code please give me answer?  
Passing a 2 Dimentional Array From one Jsp to Another Jsp file and Retreving it
Passing a 2 Dimentional Array From one Jsp to Another Jsp file and Retreving... are dynamically stored into it in one jsp file .I passed this array into another Jsp... JSP FILE 1 : // declatarion int final
passing from 1 jsp to another - JSP-Servlet
passing from 1 jsp to another  Hi Sir, What are the ways and means of passing from 1 jsp page to another page.what are the different types of methods?  Hi Friend, You can use tag,sedRedirect() method
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to insert the bulk data into the data base from the table of jsp page to another jsp page  pls help i'm doing the project called centralized... to get values in array in next jsp page and insert into the row by row Please do
calling servlet from jsp in netbeans ide
calling servlet from jsp in netbeans ide  I have tried to call servlet from jsp code in netbeans for checking the database values . but while running it showing the error that the resource not available. i dono wat mistake i did
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second... fetching data from the database on second jsp page with checkbox corresponding each
How To Include Two Jsp page in another jsp page?
How To Include Two Jsp page in another jsp page?  I use following code to Include Two Jsp Page Header and footer <%@include file="header.jsp... in page How can i Display at correct position?   Please visit
calling function - JSP-Servlet
calling function  Hai, How to call a java file in jsp file... : 1.Create a jsp page "test.jsp" Example of Extends Attribute of page Directive in JSP 2.Use "import" attribute in JSP
Calling Servlet to build a List of data from database and show this on the JSP page in table
Calling Servlet to build a List of data from database and show this on the JSP... is then added to the request object and sen to JSP page. On the JSP page this value... to the JSP page. We are using tomcat to run and test the applicationADS_TO_REPLACE_1
Passing Parameters to Another JSP Page
Passing Parameters to Another JSP Page      By using the include action we can pass the parameters to another jsp page... introduce a new request parameter when calling a jsp page. This param tag can
calling a web page when pressing on a Button - JSP-Interview Questions
calling a web page when pressing on a Button  Please perhaps I do... clicks on a Button Print, I call another web page, When the user clicks on Update, another web page will be called. For this reson, It can not defined
how to set the tables one is left and another one is right - JSP-Servlet
how to set the tables one is left and another one is right  Here two tables are combined.i need to set the one table is left another one is right and ineed to gap between the two tables Document document=new Document
Parameter passing from jsp page to jsp page - JSP-Servlet
Parameter passing from jsp page to jsp page  Hi I intends to pass the parameters that I received from previous page through query String. I get all... Welcome :  For more information on JSP visit
how can we pass parameters from jsp href to another servlet
how can we pass parameters from jsp href to another servlet  how can we pass parameters from jsp href to another servlet
How to pass parametes from JSP page to HTML page? - JSP-Servlet
How to pass parametes from JSP page to HTML page?  Hi all, In my project I have one JSP page and one HTML page. In JSP page I have created HTML... to pass the values from my JSP page to HTML page. Pls help me out. Hitendra 
insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints
jsp one to one mapping
jsp one to one mapping  how to perform one to one mapping in jsp....code of one to one mapping with .xml file
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... exactly make a link with it   Jsp edit application 1)application.jsp: <%@ page import="java.sql.*" %> <html> <head> <script
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... exactly make a link with it   Jsp edit application 1)application.jsp: <%@ page import="java.sql.*" %> <html> <head> <script
Java from JSP - JSP-Servlet
Calling Java from JSP  Does anyone have an example of Calling Java from JSP
calling web page accroding to if statement - JSP-Interview Questions
calling web page accroding to if statement  Dear, Please i have three conditions. Sample pseudocode Program: if answer = '1' I want to call the web page1 by include else if answer = '2' I want to call
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js? I set
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
calling java beans - JSP-Servlet
calling java beans  Sir, I want to know where to place the java beans java file and class file inside tomcat web server. and how to call them from jsp file.  Hi Friend, Java Bean is placed in classes\form
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page  actually i have to create dynamic... from 0-4) n on nxt page v r accessing value using request.getparameter
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this Controller request.setAttribute("msg", "Successfully Login"); In jsp ${msg} and then i
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... the value of text boxes to a jsp page and how to access the same
parser xml one page to another
parser xml one page to another  parser xml one page to another
calling zipping function - JSP-Servlet
calling zipping function  Hi, Is it possible to zip a jsp file. I wrote a java function for zipping a file.How to call that java file (zipping function ) in JSP ? pls help me Thanks.... 
jsp:include page=.. and include file = ...
;?.   <jsp:include page = ... >: This is like a function call from one jsp to another jsp. It is executed ( the included page is executed... from one jsp file required to include in multiple jsp files.ADS_TO_REPLACE_1
Fetching database field from servlet to jsp page ?
Fetching database field from servlet to jsp page ?  Hello Java... field. I wanted to pass some of the database field from servlet to jsp... (i...) field to jsp page . { where 'rs' is Resultset object} please help
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads... = DEDCHGG_PWDP and goes on... I have to create a jsp page to show these data
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity with database from my web site. In my local host-- when I am typing
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity with database from my web site. In my local host-- when I am typing following code

Ads