Meet AI 2027 Conference (Dec 1)
3 days ago
A collection of things, readings I stumble upon useful.
if (action.equals("view")){
try{
output = user.getUser(username);
md.searchGameByUserid(output, username);
md.searchAllFavorite(output, username);
user.searchSimilarUsers(output,username);
output.setAttribute("msgType", "view");
}catch(Exception ex){
output = user.getEmptyElement(username);
output.setAttribute("msgType", "saveNew");
}
}
The time stamp I used previously was from the template, and it doesn't show time very well. For example, 2009-07-21T13:06:44.670Z, a little hard to read. This is done using System.currentTimeMillis() from java.util.Date, which gives time to milliseconds, and was stored in mysql as a BIGINT.
However, there's a smart way to do this: mysql have a build-in type: TIMESTAMP, which will be responsible to keep track of time and display it properly when called. It can be called using command NOW().
String sql1 = "drop table metadata";These 2 lines of command tells the database to delete the metadata table. Then, when the servlet checks if there's a table to create, it will find none, and consequently create the new table with update.
DB.executeQuery(sql1);
I originally wrote the searchSql function repeatedly, since the query criteria are different, however, the result set are generally same. So I separated out the different part into several method:Users.java
- search(String keywords); - searches for metadata with title or description like keyword.
- browse(); - searches all metadata exist in the metadata table.
- browse(String category); - searches all metadata with matching category
Originially I had copied quiet a few methods from metadata.java to users.java because I hadn't figure out how to call methods from other classes. Now, I will call a constructor class in the UserServlet.java file:
Metadata md = MetadataServlet.geMetadataClass();
then I'll be able to call the delete method from metadata.java which delete selected game from the database. In addition, I'm able to search for all games submitted by this user from metadata.java by calling md.searchUserID(output, username)
SELECT mid FROM favorites WHERE userid = 'userid';Then, with the list of mids, I can retrieve title, author, category from metadata:
SELECT title, author, category FROM metadata WHERE mid = 'mid';then, print the result.
I has quiet some trouble making changes to add fields I want into the database, since they don't seems to take effect at all. I realize that after the table is created, no change will take effect. Therefore, I must go into mySQL database and delete the table from there using command: drop table [tablename]
I made changes to the metadata table:This caused massive change file metadata.java and metadataServlet.java, and I wasn't able to test it until almost all changes are done, since they are interconnected. They is making debugging difficult. The problem is found - a small syntax error.
- changing the name of some columns -so they fit the content they contain
- added 2 new columns: a) datestamp & b) userid - for tracking who added each entry and when
eg: http://localhost:8080/hwm/metadata.jsp?action=hit&mid=2&url=http%3A%2F%2Fwww.google.ca
Load LOCAL DB infomation:jdbc:mysql://localhost:3306/hwmSearching google on this error, shows the problem lies with connection to mySQL database. There are two possibilities:
java.sql.SQLException: Invalid authorization specification, message from server: "Access denied for user 'hwm'@'localhost' (using password: YES)"





xsl:value-of select="/x:index/@userid"
However, the root node is not always same, so the absolute path doesn't work. I tried the xpath axes; however, I'm always getting syntax error, for example:
xsl:value-of select="parent::attribute::@userid"
It seems the xslt doesn't like it with I use axis more than once. I suppose perhaps I should use a node right after parent:: ? But I need to access the parent's attribute, there's no node below for me to use. What to do? I still don't know how to use the xpath axes. I'm using a lazy method for now, but it might become problematic:
xsl:value-of select="/x:*/@userid"
xsl:value-of select="../@userid"... ... ...


