• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Component?

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I am writing a dynamic JSP page in which I want to use elements of HTML forms. One of the elements is NumericField which is just a <input type="text
"> with javascript that restricts entering any characters except numeric. I read about HTML Components (HTC) introduced by Microsoft, but there hardly any information about how to implemented. Is there any way I create a JSP component that will have an HTML element and some JavaScript that is also will be able to communicate with a server using Java syntax. I was thinking about creating a JSP page that will have all this information, but is this an efficient way to do this? Is there a way I can write a class that will return a String that represents HTML element and has parameters such as size and name based on parameters I send to this class, and also can proccess input from this element?
I am totally clueless here, any help is appreciated.
thanks,
Alex
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there a way I can write a class that will return a String that represents HTML element and has parameters such as size and name based on parameters I send to this class, and also can proccess input from this element?


I do this quite successfully using custom actions -- which, I might add, is way simpler to do (especially for the type of purpose being discussed here) using JSP 2.0 tag files.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean JSTL? Where is the best place to learn more about this?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. JSTL is an example of custom actions. I'm talking about writing your own.
For example, I have created a button component that emits an HTML button tag along with all the javascript that controls its semantics (roll-overs, active/inactive states, onclick execution, and so on). On the JSP page it's a simple little tag -- it turns into all the necessary goo on the HTML pages sent to the browser*.
* Since I have a lot of the button goo factored out into a Javascript class, even all the emitted goo isn't all that horrible. But the point is, the JSP pages look fabulous!
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
got it. Can you give an example or point to the right direction where I can learn more about this?
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
may be this is it?
http://today.java.net/pub/a/today/2003/11/14/tagfiles.html
I tried implementing example in this article but every time I run jsp page that uses a tag I get this error:

Have no idea what it means...
[ March 26, 2004: Message edited by: Alex Kravets ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. But bear in mind that tag files are just one means to create custom actions. You can also code them in Java which is sometimes preferable.
In order to utilize tag files, you need to be running a JSP 2.0 engine (Tomcat 5, Resin 3) and have your web application delcared as a servlet 2.4 web app. Otherwise, you'll need to use JSP 1.2-style custom actions which must be implemented as Java classes.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, then another question. How do I check which Servlet version I am running? With java it easy java -version, but what about servlets?
Also, you said:


Otherwise, you'll need to use JSP 1.2-style custom actions which must be implemented as Java classes.


Is this the same as using <jsp:useBean> ?
Finally,


Yes. But bear in mind that tag files are just one means to create custom actions. You can also code them in Java which is sometimes preferable.


What do you mean here? Have Java Classes that reside in WEB-INF?
[ March 26, 2004: Message edited by: Alex Kravets ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How do I check which Servlet version I am running?


Depends upon your container. Which are you using? If Tomcat, you need Tomcat 5. If Resin, the Resin 3. I'm not sure what rev the other containers are up to.

Is this the same as using <jsp:useBean> ?


No, that's a whole different mechanism. If you want to be using custom actions, you've got a lot of reading ahead of you. But it'll be well worth it; custom actions (formerly known as tag libraries) are by far the best way to create resuable JSP components.
Visit the JavaRanch Bunkhouse for reading recommendations. Or search the web for a tutorial on "custom tags".

What do you mean here? Have Java Classes that reside in WEB-INF?


Yes. Non-tag-file custom actions are implemented via Java classes that you write that extend and implement classes and interfaces provided by the javax.servlet.jsp.tagext package.
[ March 26, 2004: Message edited by: Bear Bibeault ]
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much for the info Bear!
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's information about HTC coding on the MSDN website, http://msdn.microsoft.com
Sorry, don't have the exact URL, you'll need to search.
That site is a true treasuretrove of HTML and Javascript (plus of course everything Microsoft specific) information.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately it's only a reference, sort of API. There is no good tutorial on HTC...
 
reply
    Bookmark Topic Watch Topic
  • New Topic