File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Writing JSP from scratch Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Writing JSP from scratch" Watch "Writing JSP from scratch" New topic
Author

Writing JSP from scratch

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 235
I have been programming since last 5 years. I have maintained JSPs but not written one from scratch. What I want to know is, do people first create html pages using some html editor and then convert into a JSP or they directly create JSPs. Which editor is normally used for creating JSPs in eclipse?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3373

.... do people first create html pages using some html editor and then convert into a JSP or they directly create JSPs

JSPs generate dynamic content as oppose to HTML pages which are static. But we use HTML to display the output with JSPs so the difference is we add JSP tags (which generate the dynamic content) inside the HTML.

This message was edited 1 time. Last update was at by Vijitha Kumara



SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Unless you are doing it wrong -- by putting Java code in a JSP -- a JSP will look a lot like an HTML file with some special markup in the form of JSTL tags and EL expressions, and perhaps some directives at the top.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 235
thanks for your reply. But for html I can use a lot of tools to simply drag and drop objects. For example coffeecup html editor. Can I use something similar for jsps. Or is that how people first develop their jsps?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Drag and drop JSPs? I'd rather die than let some WYSIWYG tool write code for me!

But maybe that's just me.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612
Nope, I'd let a room full of actual monkeys write my HTML before letting a WYSIWYG editor do it; easier to clean up.

(Both the code and the room.)

This message was edited 1 time. Last update was at by David Newton

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 235
So that means, all good pages that are easier to maintain are hand written. So the best way is to first design my page on paper and then write code for it?

Thanks for all your replies.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 639
There are (obviously) a lot of opinions about how you should create your JSP pages
The bottom line is that you create/edit them the same way you did your HTML pages. In fact, take any HTML page and change the extension to .jsp and you have a JSP page (a JSP page doesn't have to contain any JSP/JSTL/Whatever tags).
Use what works best for you.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Not always. Some HTML WYSIWYG tools will simply remove any JSP it finds as invalid, or worse, rearrange it so that it no longer works. Or simply crash.

All kidding aside, when it comes to the point where you are using JSP, you should be a mature enough coder to be able to code from scratch rather than relying on tools to generate code for you.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 639
I'm sorry if you think I said that all WYSIWYG editors are good. It was not my intent to imply such a ridiculous notion.

I think the choice of tool for HTML editing is a personal one. The fact that some may choose to use a WYSIWYG editor doesn't mean they are necessarily immature. I was brought up to do things without fancy editors, so that's just my personal choice. I can, however, understand how some may have been brought up using WYSIWYG and are simply more comfortable using them.

Of course, to use one that destroys JSP (or other) tags would be less than useful. I would expect that a developer choosing a tool for development would not choose one that would make the work harder.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

Sounds like we are all in violent agreement.
Aman Goel
Greenhorn

Joined: Jan 14, 2010
Posts: 15
Hi Guys. People directly write JSP pages. That's the advantage of JSP over servlet.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3373

Aman Goel wrote:People directly write JSP pages. That's the advantage of JSP over servlet.

Servlet's has it's own lifecycle methods that can be written for us by IDE's no matter what we use that servlet for. But with modern JSPs (has it's own lifecycle methods too), with it's usage (mainly for the view) what's generated by the IDE may be useless.

This message was edited 1 time. Last update was at by Vijitha Kumara

Ayoma Wijethunga
Ranch Hand

Joined: Mar 07, 2010
Posts: 38

Aman Goel wrote:Hi Guys. People directly write JSP pages. That's the advantage of JSP over servlet.


Mainly, in a servlet you write the Java code and embedded some HTML syntax in it. But with JSP you write HTML and embedded some Java code in it. Well, that's in simple language.

So in MVC, JSPs are used (and should be used) in constructing the view and Servlets are used as controllers.

So my idea is that discussing advantage of JSP over servlet is not possible because both are used in two different fields.

This message was edited 1 time. Last update was at by Ayoma Wijethunga



AyomaOnline - CodeGreed
 
 
subject: Writing JSP from scratch
 
MyEclipse, The Clear Choice