I need desperate help;

I need to extract a user id from mysql database to make the id into a session, i have tried all that i know and it doesn't. My last resort was the following code from DW and it just breaks my design. The code is; <%=(((private_d_data = private_d.getObject("private_id")) == null || private_d.wasNull()) ? "" : private_d_data)%> Does any one knows the best way to work around this.

Kwesiaryee,

It's a long while since I cut any JSP but the principles of userIDs and sessionIDs are pretty universal.

I wonder if you might be trying to match up two things that are incompatible one with the other.

As normally applied,

  • "userId" refers to a long term database key which is unique to a particular individual.
  • "sessionID" is a short term value unique to a particular user session

They are different animals.

You can indeed store a sessionID in a database, and this can be useful, but it's not generally appropriate to use cross-fertilise userID with sessionID.

Probably way off the mark but these are my immediate thoughts.

Airshow

<%=(((private_d_data = private_d.getObject("private_id")) == null || private_d.wasNull()) ? "" : private_d_data)%>

Call me dump, but since when assignment and evaluation/comparison can be done in same time?

Call me dump, but since when assignment and evaluation/comparison can be done in same time?

I blinked twice at that but think it's ok. Some languages allow embedded assignments, though I confess I haven't a clue what language this is. Execution is actually sequential - the assignment preceeds the test.

In this case, the author has made the assignment on the left side of the ? to "cache" the result of private_d.getObject("private_id") , which is presumably costly (eg database query) and would otherwise need to be called twice. Two statements would be clearer but less compact.

The bigger question is the relevance of the code to the question posed.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.