Create output file from jsp

M

Monica

Hello everyone,

I hope someone can help me. I am VERY new to jsp and need to figure
out how to do this.

I have a file named united_states.jsp which calls another file named
state.jsp when a state is selected on a map. That file uses an xml
file to place markers on the map of the selected state. Right now
everything is working fine.

Here is my problem: The xml files I am currently using are manually
created. I need to be able to generate these files dynamically from an
Oracle database. Can someone please tell me how to go about doing
this?

Thanks in advance,
Monica
 
O

Oliver Wong

Monica said:
Hello everyone,

I hope someone can help me. I am VERY new to jsp and need to figure
out how to do this.

I have a file named united_states.jsp which calls another file named
state.jsp when a state is selected on a map. That file uses an xml
file to place markers on the map of the selected state. Right now
everything is working fine.

Here is my problem: The xml files I am currently using are manually
created. I need to be able to generate these files dynamically from an
Oracle database. Can someone please tell me how to go about doing
this?

Query the database, and based on the values you get, emit the
appropriate XML data to a file. This can be as simple as using a FileWriter,
or it could involve using Castor or some other XML manipulation library to
construct an in-memory representation of the document, and serializing it to
disk.

- Oliver
 
M

Monica

Query the database, and based on the values you get, emit the
appropriate XML data to a file. This can be as simple as using a FileWriter,
or it could involve using Castor or some other XML manipulation library to
construct an in-memory representation of the document, and serializing it to
disk.

- Oliver

Thank you for responding to my post.

Could you please explain how to go about doing what you suggest (emit
the appropriate XML data to a file)? This is what I don't understand
how to do.

Thanks.
 
O

Oliver Wong

Monica said:
Thank you for responding to my post.

Could you please explain how to go about doing what you suggest (emit
the appropriate XML data to a file)? This is what I don't understand
how to do.

Let's say you want to emit the file with the contents: <foo>Hello
world!</foo>

You can do this by writting the following JavaCode:

[CODE BEGIN]
//put the appropriate imports

FileWriter fw = new FileWriter("output.xml");
PrintWriter pw = new PrintWriter(fw);
pw.println("<foo>Hello world!</foo>");
[/CODE END]

Let's say you want the contents in the foo tag to vary based on the
contents of the string variable bar. Then you'd write:

[CODE BEGIN]
//put the appropriate imports

String bar = "Hello World!";
FileWriter fw = new FileWriter("output.xml");
PrintWriter pw = new PrintWriter(fw);
pw.println("<foo>" + bar + "</foo>");
[/CODE END]

- Oliver
 
M

Monica

Let's say you want to emit the file with the contents: <foo>Hello
world!</foo>

You can do this by writting the following JavaCode:

[CODE BEGIN]
//put the appropriate imports

FileWriter fw = new FileWriter("output.xml");
PrintWriter pw = new PrintWriter(fw);
pw.println("<foo>Hello world!</foo>");
[/CODE END]

Let's say you want the contents in the foo tag to vary based on the
contents of the string variable bar. Then you'd write:

[CODE BEGIN]
//put the appropriate imports

String bar = "Hello World!";
FileWriter fw = new FileWriter("output.xml");
PrintWriter pw = new PrintWriter(fw);
pw.println("<foo>" + bar + "</foo>");
[/CODE END]

- Oliver


Thank you for explaining. I will give this a try.

Monica
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top