Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Pete Cassetta

Greenhorn
+ Follow
since Feb 13, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pete Cassetta

Originally posted by Gemini Moses:
Thanks for your reply.
I am trying to understand existing code in my new project. Can you please make it more simple for me in getting to basic level as to,
Whenever a call is made to this jsp, it is going to call, from aaa.java class setXML method.
I have aaa.java class with constructor, setXML and getXML methods in it. But when I tried printing some statements in these methods they are not seen in my log file.
Please help me!!
Awaiting fast reply...


Let's say this page is aaa.jsp. Now if you load http://www.yourdomain.com/aaa.jsp then there will be no call to setXML() because there is no request parameter named "XML." If, instead, you call it via http://www.yourdomain.com/aaa.jsp?XML="file.xml" then there will be a call to setXML("file.xml").
When you use the wildcard "*" all the request parameters are scanned, and any whose names match those of setters in the bean will cause the setter to be called with the parameter value.
Hope this clarifies somewhat...
16 years ago
JSP
There are a lot of IDE helper tools for Struts. Some are open source, some are commercial. See:
http://jakarta.apache.org/struts/resources/tools.html
I don't use any of these, so I can't recommend which is "best".
17 years ago

Originally posted by Simon Brown:
Or more specifically, the return types of your getters needs to match up with the parameter type of your setters. They don't have to just be strings.
Well, this is the rule in JDK 1.4 anyway - you can get away with breaking it under 1.3 and below. Basically, the rules around the JavaBeans mechanism have been changed to be more restrictive.


Guys,
Thanks for the detailed explanation. I had found a workaround, as you know, but it is so much more satisfying (and educational) to know what's really happening.
I probably need to buy your book Simon, as I am writing a lot of custom user-interface tags these days and getting tremendous benefit from them (as well as from some of the open source ones I've started using). Taglibs make my JSPs so much shorter and cleaner. They're great.
17 years ago
JSP
I have encountered a strange behavior in Tomcat 4.04 recently. If I write a simple tag which extends TagSupport, and one of my attributes is read/write, then Jasper bombs during compilation of any page which uses this tag attribute with a "Unable to find setter method for attribute" exception.
My reason for making some attributes read/write is that I want cooperating tags (nested inside the outer tag) to read their values. For example:
<ui:columns defaultWidth="20">
<ui:column width="25">Custom width</ui:column>
<ui:column>Default width</ui:column>
</ui:columns>
So the "columns" tag needs both a setter and a getter for the attribute "defaultWidth".
Anyway, if the "columns" tag includes a getter like:
public int getDefaultWidth() { return width; }
Then I'll get the compile error. If I make the getter non-public like so, then it's fine:
int getDefaultWidth() { return width; }
All this to ask a simple question: does the tag library standard state that attributes must be write-only?
Thanks.
17 years ago
JSP

Originally posted by Shawn Bayern:

Tomcat doesn't support JSTL out of the box.


Shawn,
Am I mistaken, or will a future release of Tomcat come with JSTL pre-installed? I thought JSTL is a part of JSP 2.0, so once a Tomcat release that supports JSP 2.0 is out, JSTL should be pre-installed.
This isn't terribly important, as it is easy enough to install JSTL, but inquiring minds want to know...
17 years ago
JSP

Originally posted by Frank Jiang:
Can anybody recommend some links of professional code examples? I bought a book from Wrox "Beginning JSP". I found the code written by different authors are quite different.
Does JSP have some kind of code standard like JavaDoc?


Frank,
I'd say the consensus among professional developers is that you don't really want to embed any Java code in JSP's at all. At least, no more than is necessary.
To accomplish this, you put your real logic in JavaBeans that get used in JavaServer pages, and repetitive items can be handled via standard (open source or commercial) or custom (write them yourself) tag libraries. I would hope your course will highlight these matters. Whether or not it does, please acquaint yourself with the JSTL. You can download it from Jakarta. There are a bunch of good tutorials on tag libraries here: tag library tutorials
Here's a long list of JSP sites; some are excellent:
JSP Sites
17 years ago
JSP

Originally posted by Rick Rodriguez:
Why JSP? What is special about a Java Server Page, over an Active Server Page.


Rick,
I've been programming in JSP/Servlets for about a year and a half. For me, the main advantages over ASP are as follows:
1) You don't have to host on a Microsoft platform. I've had serious stability, security, and reliability problems hosting on Microsoft stuff.
2) You can program in Java, rather than Visual Basic/C++/C#. Of course, if you don't like Java, or don't have Java expertise, this point is moot. But I do like Java a lot. There is an unbelievable wealth of pre-written code in the Java libraries, which enables me to write less code that is more elegant and more focused on the problem domain. Also, with the traditional ASP route, you wrote your ASP code in Jscript or VBScript, then you wrote your components in C++. That was a mess. With JSP everything you write is in Java. I'm not a fan of mixing languages, but obviously Microsoft pitches this as a benefit in .NET where you can do it all in C# (or other languages).
3) JSP offers you a wealth of prewritten code in the form of the J2EE libraries (JavaMail, DOM, SAX, etc.), tag libraries (Apache Taglibs and JSTL for starters, but there are many other open-source and commercial libraries out there), and frameworks (Struts is the most popular, but again there are at least 20 excellent open source Web frameworks available - see
The Wafer Project). Some of these are traditional frameworks, while some like wingS and Echo mimic the familiar Swing programming model.
17 years ago
JSP

Originally posted by Shawn Bayern:
Note that the Community Draft Ballot is just one milestone of many under the rules of the Java Community Process. Following Community Draft, there's a Public Draft and a Proposed Final Draft; then, the FCS specification is released.


Shawn,
I don't mean to beat a dead horse, but I was really wondering when the Public Draft would come out. I just want to see something a bit more substantive than the original proposal. That proposal indicated that during the Public Draft stage some reference implementation code would begin to be released. It seems like we should be close to seeing that now. But nobody's talking...
Thanks for all the good info you're sharing in these forums, and for the sample chapters and code you've released (not to mention the JSTL itself, which is a great step forward for JSP).
17 years ago
JSP

Originally posted by Shawn Bayern:

Faces will interoperate with JSTL, and it looks as if Faces will use an amplified version of the JSTL expression language. That is, in addition to more familiar uses of the EL, it may also use the EL for assigning data (rather than just retrieving it).
Please let me know if you have any followup questions.


Shawn,
Are you in on the JSF specification? You seem to have some information that I haven't seen publicly released yet.
Basically, my question is when will the JSF spec become public, or is it already published somewhere I haven't found? Their Web site indicates that the community has already voted on the spec:
JSF Community Ballot
I would anticipate a public release of the spec right after voting, but to the best of my knowledge that hasn't happened yet.
My question is not just academic. I'm working on a long-term project which I anticipate using JSF on, and I want to avoid spending any time building things which JSF will offer.
Thanks a bunch.
Pete Cassetta
17 years ago
JSP

Originally posted by Pradeep Bhat:
Some of my friends feel that there are some shortcomings in JSTL.


You'll have to enumerate the shortcomings to get a better response, but my experience is that JSTL is quite good. If you've tried similar tag libraries from Jakarta Taglibs or Struts, then you can use JSTL right away. The design is clean and well executed.
My only gripe is that I want more than what JSTL provides by itself. But it's understandable that JSTL had to have some boundaries. I just have to enjoy what it provides and then go beyond it where necessary. I've found some useful stuff in Jakarta taglibs that isn't in JSTL, and I'm waiting eagerly to see what is provided in JavaServer Faces. The user-interface support in JSF should be a real boon; Web developers spend a lot of time on user-interface issues, and that's the most important area (to me) which JSTL didn't try to address.
17 years ago
JSP

Now your "xml" bean (that Shawn's code references) is initialized and ready to go.
[ August 20, 2002: Message edited by: Pete Cassetta ]
[ August 21, 2002: Message edited by: Pete Cassetta ]
17 years ago
JSP

Originally posted by Frank Silbermann:
I am writing some web pages which display XML as XML (e.g., XML examples in a tutorial). I would prefer not to have to hand-code every angle-bracket. Also, since the XML is computer generated, I would prefer to have pretty-printing whitespace automatically generated.
Does anyone know of a java program available to do this, i.e. to automatically pretty-print XML source within an HTML web page?


Frank,
I think you will find this article by Henri Yandell useful:
Generating XML via Java.
I have faced this issue of writing XML myself, and have found two workable solutions: JDOM and Henri Yandell's XmlWriter class. After reading Henri's article, I corresponded with him and added a few features to XmlWriter. I'm now using it in a heavy production environment with good results.
However, JDOM is also quite efficient, very elegant, and much more full-featured than XmlWriter. You should probably become familiar with it if you are not already. See the JDOM web site for details.
17 years ago
JSP

Originally posted by Eric Peterson:
Shawn,
2) How does using JSTL compare to using Jakarta's Taglibs, or anyone else's taglibs for that matter, in regards to separating presentation from business logic and data?
Thanks.


Eric,
Separating logic and data from presentation is a bigger issue than just using a tag library. For most non-trivial applications, you will want to utilize a Web application framework such as Struts to help in making a clean separation.
There are a multitude of such frameworks (see The Wafer Project), and many of them do not even use JSP for the view layer. If you are writing a non-trivial application, do some research and settle on a framework first. If it allows JSP for the view layer, then see what tag libraries it provides, recommends, or allows. At that point you are ready to consider supplementing your toolkit with JSTL and possibly other tag libraries.
In my opinion, the momentum tag libraries are gaining is one of the big advantages of utilizing JSP for your view layer. There are already many useful tag libraries out there (such as JSTL and Jakarta Taglibs) which I incorporate into projects, and I'm quite sure the number of available tag libraries is going to mushroom in the coming months/years. This is the main reason I am reluctant to stray too far from JSP.
17 years ago
JSP
I'm surprised nobody mentioned Bruce Eckel's Thinking in Patterns with Java. It's at this URL:
http://www.mindview.net/Books/TIPatterns/
It's still a work in progress, and unfortunately I haven't read it so I can't offer an opinion. But Bruce is one of the clearest writers I've encountered (he's the author of Thinking in Java), so I think this (free) book is worth a look.
Already a lot of helpful replies, but I'll add two cents worth.
In practice, I only use recursion occasionally. But it is a wonderful programming facility, and there are two types of problems which I find easy to solve with recursion but very messy otherwise. The first is traversing a tree structure. Listing all the directories on a computer is a great example. The function just lists the current directory, calling itself for each subdirectory it finds. You can clean up the output by doing the subdirectory calls first (or last) if you like.
The other problem which I find is solved nicely by recursion is parsing/evaluating a formula which involves parentheses. Each time a parenthetical subformula is encountered, the method just calls itself on that subformula, using the result as a term in the main formula. I've also seen this problem solved by converting the expression to a tree then traversing it, by converting it to Reverse Polish Notation (which is easily evaluated using a stack), or with a very inelegant non-recursive solution.
By the way, recursion has been around a long time. People have been writing recursive functions in Assembly, Pascal, C, etc. long before Java was born. So it's not anything specific to Java.
18 years ago