The Source for Java Technology Collaboration
User: Password:



Felipe Leme

Felipe Leme's Blog

When LinkedIn met JSTL

Posted by felipeal on March 26, 2004 at 08:09 PM | Comments (5)

JSTL's SQL and XML are controversial taglibs. A lot of people complain they hurt the MVC principles, while others defend they can be useful in some situations (specially on protoypes and small projects). The truth is, both sides are right: it can causes great havoc in a MVC-based application, but it is an invaluable tool in small, time-limited projects like the one shown below

Now let's forget JSTL for a while and talk about LinkedIn, which is the motivation for this blog entry. For those who don't know it yet, LinkedIn is a tool/site for social networking management. I joined the site a couple of months ago, invited by an old college friend. Although I was skeptical about the technology in the beginning, I slowly realized it was a nice way to keep in touch with old friends - or even strengthen my relationship with new ones.

My favorite way of using LinkedIn is browsing throughout my connections' connections looking for known folks. Once I found one, I invite him to be a direction connection of mine. There are 2 ways to ask for a connection: sending a request indirectly through LinkedIn or directly by email.

Sending a request is LinkedIn's core business. It would allow you, for instance, to propose a business deal to some one you don't personally know (but is indirectly "linked" with you through your connections) and LinkedIn would charge for the service. Although I think its a nice feature and a clever business plan, it is an overkill process if you just want to get a connection with someone you already know. So, in this case, it's much simpler to just send an email message to that person. The only drawback in this approach is that many times you don't know (or don't remember) that person's email address - and that's where my JSTL-based project can be handy.

The project's goal is pretty simple and straightforward: provide a repository of names and email address of LinkedIn users that know each other somehow (for instance, my Alumni class or java.net community users). Once a name is listed, you can just click on its email address and you will be redirected to LinkedIn's invitation page (with all fields already filled). (ERRATA: this part is highlighted because it has been missing from the original blog)

Considering the project's level of importance (it could be classified as "useless geek tools"), it has to be easy to use and even easier to implement (in fact, I spent more time configuring MySQL and writing this blog than developing the project). In other words, it's a typical example of application that could be written using JSTL's Core and SQL tags.

The application consists of only 2 database tables (users and communities) and 3 JSP pages:
  • index.jsp - protected page (user must login before accessing it), allows an user to add himself to the community or send an invitation to other users
  • login.jsp - welcome page where the user selects with community he would like to access (it's necessary to know the community's password)
  • listUsers.jsp - list all users in a community, with a link for posting a LinkedIn invitation to each user (this page is included from index.jsp

Here are some code snippets (the whole "source" can be found here):

<%-- check if user is logged on --%>


   


<%-- check if user already exists in this community --%>
        
           SELECT * FROM users WHERE email = ? AND community_id = ? 
           
           
        
        
           
        

<%-- handle submission --%>

   
   
   
      
         
      

      
        
           SELECT * FROM communities WHERE id = ? AND password = ? 
           
           
        
        
           
        
        
           
           
           
           
        
        
      
   




Finally, the application URL is http://felipeal.net/liar/index.jsp. If you had the patience to read this lengthy blog till this point, please give it a try - the password for java.net is CafeBabe.

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Maybe a scripting language might be better?
    The above code has no HTML rendering in it. Maybe using a scripting language might be simpler to read & develop?

    e.g.

    http://wiki.codehaus.org/groovy/AlternativeToJspForScripting

    Posted by: jstrachan on March 26, 2004 at 10:12 PM

  • this code is unmanageable, un-resulable

    Why is this code so verbose? JSTL has a horrendous syntax, how sad.

    Posted by: mabed on March 28, 2004 at 01:35 PM

  • Maybe a scripting language might be better?
    True, that page has practically no HTML. I didn't worry about the HTML layout for 2 reasons:

    1.The point was to make a simple (but practical) application, in a very short period of time
    2.My HTML/artistic skills are pretty bad :-(

    Regarding using a scripting language, it may be simpler. In fact, that's the kind of application that is typically developed using PHP. The idea was to show that JSTL/JSP could be an alternative, not that they were the better option.

    Finally, I'm not that familiar with Groovy yet - most of the articles I read about it were related to its TCK/RI license.

    Posted by: felipeal on March 29, 2004 at 04:28 PM

  • this code is unmanageable, un-resulable
    The goal was not to make it easy to maintain or reuse, just fast to implement.
    One think that is 'horrendous' in JSTL is the need for . Fortunately, that's not necessary anymore in JSP 2.0. In fact, this code could have some more reuse if using JSP 2.0, specially through the use of tag files(for request validation or printing error messages, for instance).

    Posted by: felipeal on March 29, 2004 at 04:37 PM

  • How To Use JSTL SQL in JDeveloper 10g Preview

    I found the following tutorial on OTN:

    http://otn.oracle.com/products/jdev/tips/schalk/jstl_sql/jstl_sql.html

    Very interesting...

    Posted by: felipeal on April 01, 2004 at 04:37 PM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds