Results 1 to 4 of 4
  1. #1
    lyric0n is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default Specific Functions for URL's

    Hi,

    I would like to create servlets that are stored in a class w/ similar functions (say, meetings) and different functions are called based on the URL.

    For example:

    <server>/meeting/getMeetings calls getMeetings()
    <server>/meeting/joinMeeting?id=1 calls joinMeeting(1)

    Rather than having a different class for each URL and only being able to make changes based on GET/POST/etc.

    How would I do this?

    Thanks,
    Chris

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    Sounds like you're drifting towards a god class...:)

    Why are you opposed to different actions involving different servlets?

  3. #3
    lyric0n is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default

    I feel like it would be easier to create multiple files to perform basic actions...say one class which simply handles information about meetings, one class which handles friends list, things like that.

    Is this the way to handle it, or is best practice to put everything under a doGet/doPost, then parse it out from there?

    Thanks for the help,
    Chris

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    Get the server to do the parsing.
    That is, give each action a different servlet, or at worst stick related actions together.
    Or, best, would be to use a framework like Spring or Struts to handle all this for you.

Similar Threads

  1. How to write URL's to a file
    By DuceDuceExplorer in forum New To Java
    Replies: 3
    Last Post: 03-10-2010, 02:02 PM
  2. 2 functions
    By baze7 in forum New To Java
    Replies: 3
    Last Post: 08-14-2009, 04:41 AM
  3. Functions in jsp
    By samson in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 03-25-2009, 10:04 PM
  4. Replies: 2
    Last Post: 11-08-2008, 10:40 AM
  5. Replies: 2
    Last Post: 10-29-2008, 10:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •