How the Forums Work (Posts, ID #, etc)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: How the Forums Work (Posts, ID #, etc)

  1. #1
    Join Date
    Jul 2005
    Posts
    5

    How the Forums Work (Posts, ID #, etc)

    I am wondering if anyone could give me a brief overview of how the forums work -- esp. when someone creates a new thread.

    How exactly does the JSP know to link to that thread? Is it generating a unique ID from the database or using it's own custom code? How does it point to that thread? (I'm SO *FRUSTRATED*. I've tried to figure this one out for about a MONTH.)

    I've started to create a help desk, where it takes form data and posts it to the database. (That issue solved.) The database assigns it a unique ID -- primary key. I'm having trouble displaying the problem record for that ticket ID. (I'm new to Java and really been pulling my hair over this one for about a month.)

    Let me go into some more detail:

    I have these form objects:

    - Name
    - Technical Summary
    - Severity
    - Problem

    This is a standard html form page. The standard html page posts to a JSP page, where the JSP page uses a prepared statement to insert the form data into the database. The query page, (query.jsp) has a table, which only shows TicketID, Name, Technical Summary, and Severity. Obviously, the TicketID is an int and generated by the DB, as 1, 2, 3, 4, and so on...

    So if someone created an issue it'd be assigned a unique ticket id. Note that from the query page, it DOES not show the problem. I WANT there to be a link to get the problem record in that row.

    If anyone could help me out with this one, that would be great.

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    I think usually what you do is similar to what you have done. You assign a unique key to each "thread" and then when you list the contents of the forum you would do something like:
    Code:
    ResultSet rs = ... "SELECT primary_key, topic_name FROM threads ORDER BY primary_key DESC LIMIT 50";
    
    while( rs.hasNext() ) {
      Record r = rs.next();
      System.out.println("<a href=\"/showthread.jsp?id=" + r.field("primary_key") + "\">"+r.field("topic_name") +"</a>");
    }
    Then your showthread.jsp page will search the database for the contents of that thread and display it. You'll probably notice right away that the code above is probably very wrong syntactically, but it is the general idea, at least the way that forums are written in PHP.

    Hope this helps.
    ~evlich

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    I'm not sure how this forum works but a failsafe way to do it would be:
    Every post is assigned the forum_id, the thread_id, if the post is a reply, or a
    new unique thread_id if the post is starting a new thread. And finally, every post
    will be assigned a unique post_id.
    All new ids would of course be the increment of the previous <type>_id,
    except for the forum_id that will be fixed.
    The primary key could then be a composite key like forum_id+thread_id+post_id.

    With this setup you should be able to navigate and select in any (sensible)
    way you choose.
    Last edited by sjalle; 07-27-2005 at 01:12 PM.
    eschew obfuscation

  4. #4
    Join Date
    Jul 2005
    Posts
    5
    Can you post the correct syntax?

    THANK YOU SO MUCH FOR THE REPLY. I'm getting closer.

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Something like this:

    Code:
    String query="select * from forum_table where forum_id="+forumID+
    " and thread_id="+threadID+" order by post_id";
    if you want to list a limited subset of posts from a specified post_id:

    Code:
    String query="select * from forum_table where forum_id="+forumID+
    " and thread_id="+threadID+" and post_id >= "+startPostID+
    " order by post_id limit "+limit;
    The "order by" is not required if post_id is the last part of a composite
    primary key for the table. The order here is ASC (default) as this will list the
    posts in the proper chronological order.

    Then get a java.sql.Connection instance for DB, create a
    java.sql.Statement and get the data.
    eschew obfuscation

  6. #6
    Join Date
    Jul 2005
    Posts
    5
    I'll try it out, thank you!

    Take a look at http://leonardsokol.com/c/portal_public/login

    and login as brian and password as brian

    create a new ticket...

    then go to ticket history

    you'll then see technical issue where view complete issue...

    this really doesn't do what it's supposed, it' sjust getting the technical_issue attirbute...

    hopefully, what u sent will do the trickt, where it get s the table query, and gives me the results...

    thanxs

  7. #7
    Join Date
    Jul 2005
    Posts
    5
    Ok, I have

    <a href="Details.jsp?Id=<%=Id%>">View More Information</a></font></TD>

    which there returns if I hover over the hyperlink View More Information:

    http://localhost/Details.jsp?=id_num

    so it works...
    http://localhost/Details.jsp?=5 or http://localhost/Details.jsp?=4, and so on... cordinating with the table...

    How do I get that from Details.jsp? How do I get that number or Id?

    attribute and request paraemter don't work (at least hwo im coding it.)

  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    If I understand you correctly you manage to get one parameter. Why not send a
    formatted, using some delimiter to separate parameter valiues,that you can split into
    the params you want. Yes, I know its kinda hacky, but then again, I'm a pragmatic
    person...

    If the problem is navigating through the db, you should post the SQL for
    creating the DB, at least the parts you use here.
    eschew obfuscation

  9. #9
    Join Date
    Jul 2005
    Posts
    5
    Yep, I finally got it to work.

    How would I post threads?

  10. #10
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    You click "Post Reply", and zip the sql for creating the DB and use the "manage
    Attachments" button to upload the zip file here.
    eschew obfuscation

Similar Threads

  1. Data Entry Work
    By Anjana Jonathan in forum Careers
    Replies: 5
    Last Post: 07-03-2006, 04:15 AM
  2. ASP.NET Web Forums Live
    By ASPSmith Training in forum dotnet.announcements
    Replies: 0
    Last Post: 06-14-2002, 08:36 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center