Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP's & HTML

 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read that a limitation with JSP's is that you have to insert all of the HTML in with the JAVA code. Is there a way to integrate JSP's with HTML generated from an HTML editor such as Dreamweaver? I'm just looking for the easiest way to put the JSP's together.
Thanks,
Mike
 
Yamuna Pattathil
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe what u said is not correct and is a fact about servlets. Using jsp we can just use plain html and java code is written within scripting elements
 
Dustin Marx
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could actually have a JSP with only HTML in it (but with a .jsp extension) and it would work. So, really, what some people don't like is the mixing of Java directly inside this HTML with scriptlets or expressions. To get around this, JavaBeans can be used in conjunction with <jsp:useBean>, <jsp:getProperty>, and <jsp:setProperty> to move some of the Java syntax out of the JSP and into JavaBeans. Custom tags can also be utilized by writing Java class handlers that incorporate much of the Java functionality that would otherwise have been mixed with the HTML in the JSP.
If you are not worried about maintainability (such as for a class project), it is probably easiest to just write the HTML and incorporate Java where dynamic behavior is needed using scriptlets and expressions.
 
sachin dabhade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you said is true for servlets and not for jsp.
in servlets you have to embed the html tags in your java file.
about jsp you can use html and jsp altogether to give the dynamic effect where you want and static else where.
sachin
 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate all the replies. I've primarily used JAVA with a few servlets...so I'm pretty new at it.
Originally posted by Dustin Marx:
You could actually have a JSP with only HTML in it (but with a .jsp extension) and it would work. So, really, what some people don't like is the mixing of Java directly inside this HTML with scriptlets or expressions. To get around this, JavaBeans can be used in conjunction with <jsp:useBean>, <jsp:getProperty>, and <jsp:setProperty> to move some of the Java syntax out of the JSP and into JavaBeans. Custom tags can also be utilized by writing Java class handlers that incorporate much of the Java functionality that would otherwise have been mixed with the HTML in the JSP.
If you are not worried about maintainability (such as for a class project), it is probably easiest to just write the HTML and incorporate Java where dynamic behavior is needed using scriptlets and expressions.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic