Sign in to follow this  

[web] JSP and XML questions ...

This topic is 4377 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone. First, I have looked on the internet for information on both JSP and XML. I have found plenty of resources explaining what they are, etc. But my questions... JSP: What is the purpose of JSP? Why use JSP? What types of web sites is JSP aimed for? XML: What does XML do? Why use XML? When should one use XML? I know they're pretty stupid questions. But I would like to know a little more about them. Thanks in advance, Matt U.

Share this post


Link to post
Share on other sites
Quote:

What is the purpose of JSP?
Why use JSP?

JSP is intended to make it easy to create HTML and other text-based kinds of ouptut from Java code. Java Server Pages are compiled into servlets at runtime. You can write entire applications in JSP, but that is generally frowned upon. It is best used in combination with a framework that facilitates MVC separation and database access, such as The Spring Framework.

Quote:
What types of web sites is JSP aimed for?

It can be used any time you need to generate content on the fly. JSP scales pretty well.

Quote:
What does XML do?

Simply put, it describes data in a human readable format.
Quote:
Why use XML?

It's everywhere; XHTML, SVG, XAML, XUL, the list goes on and on. Using XSLT, you can transform XML from one format to another easily.
Quote:
When should one use XML?

When you need to publish data on the web, when you need a platform independent way to serialize and deserialize objects, when you need a flexible configuration file format without having to write a parser, etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by TFS_Waldo
What is the purpose of JSP?


Sun jumping on the bandwagon of Microsoft's ASP, realising that web developers seemed to want a way of mixing code and HTML

Quote:

Why use JSP?


Conventionally, because you're too much of a wuss to write a Java Servlet.

Quote:

What types of web sites is JSP aimed for?


Things maintained by people who don't have the ability, tools or inclination to write Java Servlets.

Quote:

What does XML do?


Absolutely nothing, it's just a general purpose extensible file format.

Quote:
Why use XML?


Many reasons
- XML is a WELL DEFINED format for storing text (well, usually text) data in a structured format
- XML is extensible, i.e. if you have a schema you want to add something to, you can add it, and applications which don't understand that part should ignore it. This would be more tricky with (for example) a delimited or fixed-record file.
- XML takes care of some of the messier issues around, notably character encoding and escaping that would otherwise annoy you making your own text file format. You might even overlook them if making your own.
- XML is in most cases, HUMAN READABLE, so that it's possible to verify that the data appear correct manually.
- XML insists that its files are WELL FORMED, thus stopping applications from breaking the rules which govern character encoding, escaping etc (NOTE: there are some widely used XML applications which ignore this in the standard and accept badly formed files anyway)

Quote:

When should one use XML?


ONLY if you need to interchange data with other people or other peoples' applications. Generally speaking, if your data only needs to be read by your own code, there is little benefit. Some other format will probably be easier to work with.

Of course if you've already got tools which either emit or accept XML, it might be useful for your code to do so too.

Contrary to popular belief, using XML does not automatically make applications able to talk to each other. They still have to agree on a schema.

Also, I've found when doing integration, a lot of developers don't seem to understand XML very well, and produce and/or accept badly-formed (or invalid) XML.

When should you NOT use XML:

- If you need to store a large amount of data efficiently - XML adds a great deal of size to your files.
- If you need to read/write data efficiently - depending on the API and the schema, XML can be very inefficient to read/write compared to some other format.
- If you need to store (a significant amount of) binary data - XML has no standard way of doing this.
- For the sake of it.

Mark

Share this post


Link to post
Share on other sites
Quote:

Conventionally, because you're too much of a wuss to write a Java Servlet.

Quote:

Things maintained by people who don't have the ability, tools or inclination to write Java Servlets.

I smell flamebait. If that wasn't inteded to be a troll, you have been seriously misled.
JSP was designed with MVC in mind, but for very simple dynamic pages it would be a PITA to have to write a controller class and wire everything up.

I really hope you haven't been littering your servlet code with hundreds of out.println()'s.

Share this post


Link to post
Share on other sites

This topic is 4377 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this