H Wilson

Ranch Hand
+ Follow
since Feb 23, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by H Wilson

Considering what I had blamed for, I'd almost rather share a toothbrush than a Linux server!
20 years ago
Thanks. The problem turned out to be something else entirely. In the words of an astute colleague:

" We've finally arrived at how the changes got overridden. CVS stores all version information in a file called CVS/Entries. When two people share the same machine, they do an update in the [dev] folder thereby the version information will always be the latest. However, since they both work with older versions of the files, CVS has not way of knowing that and when they copy the files back to [dev], CVS will treat them as current and not merge any changes back.
The solution is either get new machines or set up separate log-in accounts."
20 years ago
I was under the impression that cvs could merge concurrent code changes to one file. For example, Bob makes changes to SomeFile.java and commits those changes in cvs. Anna was also working on SomeFile.java at the same time Bob was. When she is ready to commit her changes, she first executes the cvs update command and gets a 'M' message for that file. I had thought this 'M' meant that Bob's changes were successfully merged with Anna's file and that she could now safely commit her changes, preserving both Bob's last commit and her changes. However, I have had numerous problems with this situation in that I have overwritten other developers' changes. Does cvs actually have this merge function I was told it did? What could be going wrong?

Thanks in advance.
20 years ago
Also, why does your setRequest() method take an HttpServletRequest parameter? It doesn't use this object and you would only be able to call this method from an object that has access to such object. A servlet does have access to the request object and is a good place to create your beans, but I don't think you're creating this bean in a servlet, are you? It's simply being instantiated in the JSP (I know, a JSP is really a servlet and it has access to the request object, but... ). Besides, you'd have to instantiate the bean and then call the setRequest() method with the request object as a parameter. Why not get any value you need from the request object and use that value to set a property in the bean instead of passing the request object itself to the bean?
20 years ago
Sorry, I guess my last post didn't make much sense in light of the fact that the properties you are displaying are set in the bean with the results of the query. My apologies.

From your code, it looks like the query never gets run because it's in the setRequest() method. How would this method ever get called? Why don't you call setRequest() from the constructor if you're not going to use a parameter from the query string for the someid value? If you do want to use the query string parameter, then you'll have to set the value of a property with it and then call setRequest() to run the query.
20 years ago

Originally posted by Timy McTipperstan:

<jsp:useBean id="someclass" scope="page" class="com.fh.db.SomeClass" />

<jsp:getProperty name="someclass" property="var1" /></<br>
<jsp:getProperty name="someclass" property="var2" /><br><br>

and i tried

<%=category.getVar1()%><br>
<%=category.getVar2()%><br><br>



If you really are using "someclass" for the id of your bean, your output scripting code needs to use that as well:

<%=someclass.getVar1()%><br>
<%=someclass.getVar2()%><br><br>

But no matter which id/name you use for the bean, and whether you use the getProperty tag or the scripting tags, you must set the value of a property before getting it. After the useBean tag, insert a setProperty tag with the value set to the request parameter.
20 years ago

Originally posted by Jenn Person:

My problem is... when I start my application and it begins at index.jsp... I have no way of querying the database to get those category titles.



Oh, yes you do! You can use a bean ... with application scope.

<jsp:useBean id="myDatabaseQueryingBean" class="myPackage.myBeanClass" scope="application" />

Put your JDBC code in the bean and access the result set for display in the JSP with a tag from the JSTL!

Good luck!
20 years ago

Originally posted by Timy McTipperstan:
Someid will be taken from the URL that is passed in from the previous page. somejsp.jsp?someid=5, I put 5 in the sql because I was trying to at least be able to get something out of the rs, ahh no luck with that.

I'm not even sure if this is a good way of doing it. Any thoughts?



Yes, you can do it that way, but you need to pass that value to the bean with the <jsp:setProperty> tag. Putting the parameter in the url is actually a "GET" request, so you still have to process the request object to obtain that value. Your tag should look something like this:

<jsp:useBean id="yourBeanId" scope="page" class="yourPackage.yourClass" />
<jsp:setProperty name="yourBeanId" value="*" />

The above example will work where all the names of the parameters in the query string have corresponding properties with matching names in the bean. Otherwise, you have to set each property explicitly, but the syntax for the value parameter of setProperty differs depending on if you are using the Expression Language from JSP 2.0 or scripting tags from JSP 1.2

To display the data in the JSP, you need to write some display code. You could define a property in the bean that returns a string containing the text, xml or html that you need. Then you would want the use the <jsp:getProperty> tag. Otherwise, you can try the Standard Tag Library or write your own custom tag that makes use of the data in the bean.
20 years ago
Sorry, I think my first post was too hasty. It looks like you began with a servlet and then decided put the data access code in a bean that you are using in a JSP. That's fine, but where does the request originate?

If you want user input for that "someid" field, you need a page with a form that does either a POST or a GET to a servlet or a JSP. In the doPost() or doGet() method of the servlet, you want to get your "someid" parameter from a field in the form (unless you ALWAYS want to use the integer constant 5) with request.getParameter("form_field_name"). Then create your bean using this value, execute the JDBC code, get your result set, perhaps storing it in an array and finally return to the jsp where you will display the data.

Whether or not you want to use a parameter from a form submission, you can create the bean and use it in the jsp, but you still have to process the result set somehow to display the data. How about using something from the Standard Tag Library or writing your own custom tag?
20 years ago

Originally posted by Timy McTipperstan:
Here is what I updated it too, any thoughts?

public class SomeClass implements java.io.Serializable {



First, I don't see where you are returning the data. Do you want to display the data in a JSP? I think your JDBC code may be fine, but you don't appear to be doing anything with the result set you've generated. Perhaps you didn't include that code. Also, is there some reason why you switched from an HttpServlet to the above object, which simply extends Object?
20 years ago

Originally posted by DC Dalton:
Thanks, Id actually like to see it ...... I was able to get the data back (im pulling data from a db) by using PrintWriter but MAN that seems weird sending it back that way! Maybe Im making too much of it but it just doesnt seem like the right way to do it!

Thanks Again!



You can also redirect or forward to a jsp. You can actually forward or redirect to just about any url, but I'm guessing that since you have data to display, you might want to store the data in a bean and display it in a jsp that has access to that bean. Check out the javadocs on javax.servlet.RequestDispatcher for the forward() method and javax.servlet.http.ServletResponse for the sendRedirect() method. I think Marty Hall's book "Core Java Servlets and Java ServerPages" may contain a good explanation of these methods (can't remember offhand as I read it some time ago) and I'm sure that "Head First Servlets and JSP" does. You want to call one of these methods at the end of your doGet() or doPost().
20 years ago
I am in the analysis phase of a project with the following specs (in a nutshell):

Allow users to save their searches for the journals in our database and receive via email periodic reports (they may choose a frequency of daily, weekly, monthly) listing new journals added to our database matching their search.

It seems obvious that I want to create a table containing fields for the actual search (query text), the user id, email address to send the report to, the frequency of the report, the date report was last run, and the date the report expires. (Those are the essential fields. I may discover additional fields as I delve further into this project.)

The application will run a nightly cron job to generate the reports. In my idea for its implementation, it would iterate over the search table described above, creating and emailing each report. Actually, I will probably query the search table for reports that are due to run that night and iterate over that result set.

My question here is about the use of a servlet for this job. Couldn't I create one object to iterate through the "reports due" result set and submit the process of creating and emailing the reports to a servlet? I'm thinking that such an implementation would allow for a multi-threaded solution. Obviously, iterating over a result set is sequential, but if I call a servlet to do the actual processing, don't I have multi-threading in that the app could call the servlet again before finishing each request? The iterating object would not have to wait for the servlet to finish generating one report before going to the next record in the result set and calling the servlet again, right?

Is there a better way to handle this process?

Sorry for the lengthy post and thanks in advance.
20 years ago

Originally posted by pratap maha:
Hi -
I am in a dilema if I have to use a JApplet to build a rich GUI on the clinet side.



Are you saying, "Do I have to use an applet in order to get a rich GUI on the client side?" If you want something significantly richer than what html provides, I think the answer may be "yes."
20 years ago
JSF

Originally posted by Daoyue Ming:
Currently I need to implement a web interface for search & enquiry of databases.
The senario is there is a page to provide search criterion, the criterion may comes from column A from Table 1, column B from table 2 (all thse tables can be joined). After speicified these criterion, the search result can display fields from various columns of various table.
Is there any framework does it?



Sounds like a great assignment for learning the Java Servlet and JDBC APIs
20 years ago

Originally posted by grace chow:

if there is duplicate login, I wanna to logout the previous login.
I have the previous session ID, I wanna to know if it is possible to remove th previous session using this session id .so the the previous login will be invalidated.



There is an invalidate() method in the javax.servlet.http.HttpSession object. That would probably do it. Although, if you only have the session id and not the actual object, I'm not sure if you could get the HttpSession object. You could also use setMaxInactiveInterval() when you first create the sessions to something rather brief so that the old session (presumably inactive) would expire on its own. That could cause be a problem if your users will spend a lot of time being inactive -- their sessions will keep expiring.

How is it your users would be logging in twice?
20 years ago
JSP