Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Create output file from jsp

Thread view: 
Monica - 01 Jun 2006 16:40 GMT
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
Oliver Wong - 01 Jun 2006 17:32 GMT
> Hello everyone,
>
[quoted text clipped - 10 lines]
> 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
Monica - 01 Jun 2006 19:02 GMT
>     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,
[quoted text clipped - 3 lines]
>
>     - 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.
Oliver Wong - 02 Jun 2006 14:51 GMT
>>     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
[quoted text clipped - 12 lines]
> 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
Monica - 02 Jun 2006 16:30 GMT
>     Let's say you want to emit the file with the contents: <foo>Hello
> world!</foo>
[quoted text clipped - 22 lines]
>
>     - Oliver

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

Monica


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.