~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> By number of characters l mean not punctuation or a space

Look into the isLetter method of the Character class; modify your logic to increment the count only if the above method returns true .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Does [0-9] need to be in quotes?

No, it needs to be placed inside forward slashes to be considered as a regular expression. Of course, if you place them inside quotes, you need to explicitly use the RegExp() constructor.

@vishalanuj
That regex won't work. Try something like:

// This restricts the pin code to only digits with at least one
// digit required.
/^[0-9]+$/.test(txtField.value)
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Can i remove that duplicated post ??

Just report that post using the "Flag Bad Post" option and it should get appropriately handled.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> You don't need to do the conversion to int and back; just send the
> double in text format and parseDouble(...) at the Java end.

I don't think that would handle values like +INF, -INF and NaN or even deal with the obvious truncation of values [think 1/3].

@Domenzup
Even though it might be a bit more work for you, your best bet would to rely on a data transfer format/specification which does the job of converting the double to a string and back *without* any loss and in a portable manner. Using a in-house hacked version to transfer data is something I won't recommend.

If you need an enterprisy solution, go with XML. JSON is another option which is fast along with being portable. Of course there are many other data transfer formats out there like ProtoBuffer but these are most widely used ones.

For libraries which deal with converting C++ to and from JSON to Java, see here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> No, I mean for people who don't want to install another FF plugin (b/c
> low resources for so many plugins, etc) but who already have an
> adblocker installed.

Yes again. If you already have an adblocker like 'Ad Blocker Plus' installed, you can block the entire 'addthis' domain. But I'm pretty sure it isn't something much to worry about since it requires creating custom rules to block the 'addthis' domain, which I know 99% of the people won't bother doing / won't know of.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> sos, do you think that blocking addthis with an adblocker would work?

Yes, it does work. Plus, NoScript isn't exactly an adblocker. See attached.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I have gotten soooo many mixed opinions lately, and I was wondering what you guys thought of the current style. Please be brutally honest. [snip...]

Apart from the top portion of each post which houses the timestamp along with the vote-up links everything looks pretty decent. I still miss the plain old code tags which didn't force the numbering on you.

i think the most grievous offender is the row of "share this" "send that" "bookmark" "yadda yadda" buttons... I think they're ugly and extremely distracting/annoying. i would get rid of all that, because i never use any of that stuff. i think it would go a long way to cleaning up the clutter.

If you are using Firefox, try the NoScript extension to block the 'addthis' domain and your problem should go away.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> is it impossible to do it without that active x?

AFAIK, yes, it's not possible.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I want it to have always 1 row length even it is as long as a novel.

AFAIK, you can't, at least not unless you are using some excel manipulation API like POI.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, as long as it's not a space, it would work. For a more standardized naming approach, trying replacing the underscore with a hyphen.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are many good books, blog posts and articles out there for getting started with JEE; your best bet would be the free JEE 5 tutorial hosted by Sun.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> However, I do understand your point and so I did make some
> adjustments [snip]

Sounds good enough, it shouldn't be a problem as long as this whole thing is configurable. And the initial rep/post count restriction should be enough to deter spammers and other evil doers ;-)

Good job, keep it up. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>Oh I see, you replaced the existing tags with spam.

Maybe you missed some of the important points of my previous post. My point being, if a member with zero posts can edit the tags for a given thread, nothing prevents him from automating the same. Think of it as being along the same lines like the programmatic rep-attack which happened about a year back initiated by Rashakil.

iamthwee commented: my concern exactly +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> [snip]Plus, tags can be easily removed by moderators and there is a
> limit to the number of tags that can be applied to any given thread, how
> many can be applied by the thread starter. [snip] Severe abuse of the
> tag functionality will be added to the forum rules as a no-no.

But you are still missing the point. Let's say that I decide to screw around with the tag functionality to promote my site "sos.net". I fire-off a greasemonkey script or write a simple HttpClient which:
- traverses each thread [pretty simple with the sequential ids]
- edit each thread tag, un-check the existing ones and add tags like "www.sos.net", "programming-articles", "anime-fan", "hentai-fan", "more-spam" etc.
- rinse and repeat this for each thread [and yes, this can be easily done using a greasemonkey script]

I hope you see the problem now. No matter what the punishment be or the capability of mods being able to edit tags, you are pretty much hosed since along with losing your existing tags, you are a target of some smart spam marketing. Even if you have a backup of all the tags, bringing things back in action would take some time.

I do understand that you are very much excited about this collaborative editing of tags but posing some minimum requirement like at least 50 rep points or at least 100 posts might make more sense …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> The idea is that the masses may want to tag a thread in a way that the
> thread [snip]

I do understand the rationale behind your using tags but concerned about the ways in which they can get abused. As long as you are aware of those issues, its cool with me.

> Tag clouds never have borders

Not *never*, normally maybe? Take a look at this.

>I am thinking I am most likely going to change it to conform more to universal standards

Sounds good but needs to be taken on priority since you wouldn't want to have a lot of legacy multi-word tags floating around along with the standardized single-word tags.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

JNI would be too low level; try something like SWIG or JNA.

Ezzaral commented: Great! I wasn't aware of those. +25
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> also, would this be something to do with JavaEE instead of JavaSE?

Depends on what you need to learn and where your expertise lies, but yeah, nowadays the core business functionality *is* developed using JEE.

You can develop a core business functionality using web services i.e. expose your business logic using web services. You can then use a web-client developed using any one of the web development MVC frameworks out there along with a standalone client developed using Swing, SWT etc. In short, a web and standalone client for consuming a business functionality exposed as web services [which are nothing but just glorified servlets].

A serious web application might be a policy management system wherein you sell policies to customers, customers pay their premium, you generate an invoice etc. But then again, these *serious* business apps might just put you off and you'd lose motivation easily.

It'd be better to start off with something which you find fun. Something like an online TODO list application, a web application which helps you maintain a list of all the cartoons you have seen till date, an online text to PDF converter [easy since you can use the libraries out there] etc. The possibilities are infinite...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Allowing thread owners to tag their threads seems like a nice idea; if properly used can be used to easily hunt down difficult to search threads.

But allowing *everyone* to mess around with the tags of each and every thread kinda seems twisted. I guess I understand your rationale behind this one, to increase the adoption of this new tag feature, but still...I'm with iamthwee regarding this one.

Also, could you add a thin border around each tag? Single word tags work great but when mixed with multi-word tags, they kinda make little sense and are confusing from a UI perspective. For e.g. if you look at the tag cloud generated at the bottom of this page, what do you think the tags are? Is it "tag", "cloud", "tags", "thread" and "tagging" or "tag cloud", "tags" and "thread tagging" or so on and so forth.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> The local memory is not reconciled with the main memory

This might be because of each Thread is having a cached copy of your data; using the volatile keyword might just do the job.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you are using the connection pooling mechanism provided by the container instead of creating your own connection pool [as mentioned in my first post], you need to:
- remove the database related initialization parameters since you won't be coding the connection pool creation.
- change the code in your ServletContextListener class
- add extra configuration in the deployment descriptor i.e. the resource-ref element

Read this for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> All these colorful appearance of daniweb makes me get the impression
> that this site is friendly and supports freedom of speech until one ...
> turkish flagged my post as bad

This site doesn't support freedom of speech and hence is friendly. Like I have previously mentioned elsewhere, if you want to vent your personal frustrations and let the world know what you think of XXX, creating your blog would be a nice idea. Posting disturbing things like cursing a religion or nation which seems to be your idea of "freedom of speech" is not allowed here, and for a good reason IMO.

Anyways, good bye and thank you for your technical contributions to Daniweb. Maybe one day when you'll gain enough wisdom to understand what you did wrong by posting such things on a public forum, Daniweb would welcome you again.

-sos

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I fancy Dani mentioning that Daniweb search is powered by Google so it wouldn't surprise me if the search is performed against a snapshot and not live data.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAICT, there is no such method which does that. BTW, why would you want such a method? Why not just manipulate the source array first and then add it to the ByteBuffer?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> But in second, I am getting exception that filenotfound.

Because the file "spring.xml" is not present at the root of the class path; you need to state the hierarchy or the path to your config file from the classpath root.

> In my web application configuration file is located exactly in WEB-INF folder

I couldn't find any statement in the servlet specification which said that the entire WEB-INF folder is added to the classpath; the servlet specification states that:

The contents of the WEB-INF directory are:
• The /WEB-INF/web.xml deployment descriptor.
• The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.
• The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets, beans, and other utility classes useful to theWeb application. TheWeb application class loader must be able to load classes from any of these archive files.

TheWeb application class loader must load classes from the WEB-INF/ classes directory first, and then from library JARs in the WEB-INF/lib directory.

Given the above excerpt, just ensure that your application context file lies inside the folder "classes" and it should work out fine.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"Stops running" is a pretty vague description; have you looked at the server logs? BTW, reading this article might help you get things done the right way.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The way binding normally works is that you bind UI controls to properties of an object/instance. This is done because in most of the cases there is no way you can detect changes to standalone variables. Simply put, you bind properties of a model to UI controls and leave the updation of display to the events raised by the binding implementation.

In your case having something like ${object.stringVariable} instead of ${stringVariable} might just do the job; read the API of the library you are using for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your second file is missing the class imports. I don't see the declaration of your `Convert' enum class. Your naming conventions are still off.

These are pretty simple error messages to hunt down and fix; I'd recommend reading the sticky at the top of the forum.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>i also tried firefox but i didnt like it because of its limited javascript and
>css support

Wha..? Oh, you are joking, right?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ooh, ooh, how come I didn't notice this thread? Anyways, try guessing this for starters; simple of course:

An extremely Smart and Lazy ninja; dislikes tobacco smoke and anything that is too troublesome.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A few observations:
- Always perform resource cleanup in the `finally' block to be rest assured that the cleanup indeed is performed even if the code ends up throwing an exception.
- The way you have written your code resembles the procedural ad-hoc way of writing code. Break up your logic in methods and create logical classes which represent your problem domain.

Taking a look at the sticky created at the top of the forum might just help you get started in the right direction.

majestic0110 commented: Sound advice. +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thinking about it in this way might help your cause:

power(2, 3) =>

 - 2 * power(2, 2)
   - 2 * (2 * power(2, 1))
     - 2 * (2 * (2 * power(2, 0)))
   - 2 * (2 * (2 * 1))
 - 2 * (2 * 2)

= 8

The trick here is to force the repetition of `base' for an `exponent' number of times by using recursion.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>Thanks a lot guys for the help!

Good luck with the remaining exercises.

> I will flag this as solved when I get my account fixed.

Done and done. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The point I was trying to make is that instead of having a configuration like in this post, it'd be better to declare the initialization parameters at the web app level instead of declaring it for each and every servlet. You then configure a ServletContextListener i.e. create a class which receives a servlet context notifications like creation of a servlet context and it's destruction.

You can then use the contextInitialized() method to either create your own pooled datasource and push its reference in the application context or read in the database config parameters like database details, username and password and place them in the context. Now whenever you want a db connection you either retrieve the datasource or manually create a connection based on the database details pushed in the context. A sample:

<!-- Your deployment descriptor -->
<web-app>
  <context-param>
    <param-name>DB_URI</param-name>
    <param-value>jdbc:oracle:thin:scott/tiger@myhost:1521:mysid</param-value>
  </context-param>
  <context-param>
    <param-name>DB_USER</param-name>
    <param-value>scott</param-value>
  </context-param>
  <context-param>
    <param-name>DB_PWD</param-name>
    <param-value>tiger</param-value>
  </context-param>

  <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>mypkg.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>Login.do</url-pattern>
  </servlet-mapping>

  <listener>
    <listener-class>mypkg.MyContextListener</listener-class>
  </listener>
</web-app>
package mypkg;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import java.myconnpool.library.MyDataSource;

public class MyContextListener implements ServletContextListener {

  @Override
  public void contextInitialized(ServletContextEvent event) {
      ServletContext context = event.getServletContext();

      String uri = context.getInitParameter("DB_URI");
      String user = context.getInitParameter("DB_USER");
      String user = context.getInitParameter("DB_PWD");
      
      // Create a datasource using any of the connection pooling
      // libraries out there
      MyDataSource mds =
        MyDataSource.createDataSource(uri, user, pass);
      context.setAttribute("DS", mds);
  }

  @Override
  public void contextDestroyed(ServletContextEvent event) {
    // Close the datasource using the API of the connection pool library
    // you have used
    ServletContext …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> According to thread MVC above, I create web.xml like this

Don't repeat your database configuration; what you need is not a servlet level initialization i.e. ServletConfig but application level initialization i.e. ServletContext.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>Is it possible to do this type of pagination thru client side scripting...

Not just client side scripting unless you plan on retrieving *all* the records in a single go and looping or rendering them selectively. This is certainly not recommended since you end up retrieving data which might not even be used by the client along with the obvious performance implications.

> Pagination requires both, server code (java) and client code (xhtml, javascript).

Client side scripting is a good to have usability feature but definitely not necessary for implementing pagination.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sorry, but as per the forum rules, no effort == no help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sorry, but as per the forum rules, no effort == no help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Read the contract of the substring method; substring(4, 6) == 2 characters.

Also get in the habit of using uppercase characters for enums i.e. `BIN' instead of `bin'.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> when we are giving print from the client it does it print in client but its
> get print in the server

This is because the code you have written gets executed on the server. In a typical web app setting, you don't [and shouldn't IMO] have control over the client environment. AFAIK, the best way would be to initiate a print request using Javascript and hope that the client has javascript enabled.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If we had no-cache headers with our traffic levels bandwidth usage would be completely out of control.

I never said 'no-cache' headers; I said 'appropriate' cache headers. :-)

Seriously, there are a couple of ways to prevent this problem. You might want to set a header which checks for ETags or the fresheness of resources before downloading them. Or you might take the simple approach of renaming your files on every deployment and you can be rest assured that the updated resources *would* be downloaded by the browser automatically. Food for thought in case you are interested:

- Version your CSS and Javascript files
- Caching tutorial
- Cahing javascript safely

-sos

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Clear your browser cache.

Any reasons why you are not sending appropriate HTTP cache headers?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Aren't web languages also programming languages or do you disagree?

Though a majority of the developers out there regard HTML as a programming language, practically speaking, it isn't. It's a *markup* languauge.

BTW, it's Java and ActionScript for me ATM with a bit of Ruby thrown in here and there.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How do I do that....I'm very new to Java

Steps:

  • Declare a TreeSet<String> instance variable for your class
  • Read the file using Scanner
  • For each line read, create the PublisherRecord instance as per your requirement
  • Push or add the publisher name to the TreeSet
  • After the file parsing is complete, your TreeSet will contain the list of unique publisher names
  • Write a separate method to print the contents of the TreeSet as desired

> 5 1/2 weeks not enough time to absorb it all.

That should be more than enough IMO given that reading the documentation of the TreeSet class and absorbing the examples doesn't take more than a day even if you are new to Java programming [and not programming in general].

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There is no `implements' keyword when using generics syntax. Irrespective of whether you are restricting your type to a particular class or an interface, you use "extends". So your SortedTrio should look something like:

class SortedTrio<T extends Comparable<? super T>> extends Trio<T>

This roughly reads as "SortedTrio consists of elements of type T where the reference type T is a Comparable. SortedTrio in turn extends the class Trio having elements of type T". The Comparable<? super T> part ensures that if a child class doesn't implement the Comparable interface, the compareTo implementation of its parent classes can be used.

I'd recommend reading Generics tutorial to get a good hang of things.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Can we all now stop with this and12 bashing please? Though and12 made a selfish request in this thread, he has nowhere come across as being rude. He asked a question and was given an appropriate answer by the forum moderator.

Daniweb regulars ganging up on a new member isn't a very pleasant sight. Though Daniweb has always appreciated and encouraged member contributions, backseat moderation and sarcasm never was and never will be instrumental in handling forum issues. I hope you all understand this. BTW, closed lest this turns into something nasty.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Using the TreeSet class, how do I accomplish this

It's pretty simple; just keep on reading the lines from the text file and add the last entry i.e. the publisher name to a TreeSet<String> . So you'd probably have a `parse' method which would take a File instance [the handle to the data file] and a method which returns the list of all publisher names in the TreeSet. Of course, to make it more *OO*, you need to put in a bit more effort when structuring your classes.

BTW, package names should always contain only lowercase characters. Don't catch exceptions if you are anyways not going to do anything specific with them. Try to break processing logic and the data concerning the logic into separate classes rather than having a single class with lot of static members.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I think I need multiple loops to get rid of the commas, dollar sign, and
> end bracket separately.

Not required IMO; a single application of the replaceAll method of the String class on each line read should do the job. Use a regular expression for your task.

public class TrioTest {
   
   public static void main(final String[] args) {
      String s = "[2H, 4C, KC, 5D] $10 [QS, QD] $5 [AC, 3C, 4D] $25 [10H, 5C, 7H]";
      Pattern pat = Pattern.compile("[$,\\[\\]]");
      System.out.println(pat);
      Matcher mat = pat.matcher(s);
      String newS = mat.replaceAll("");
      System.out.println("Old S: " + s + "\nNew S: " + newS);
   }

}

Or, simply use the `replace' method of the String class to strip off each unrequired character from the target string.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO, you don't need a List when creating a Trio; I'd personally swap the usage of List in Trio and SortedTrio i.e. make Trio have three variables first, second & third whereas use a List only when the sorting functionality is required.

Also, you don't need to manually sort the Trio. As long as the elements of the SortedTrio [T] implement the Comparable interface i.e. implement natural ordering, the Collections#sort method can be used to get the job done. So, the simplest solution here would be to restrict the domain of the generic type T i.e. make sure each T added to the SortedTrio is an instance of the Comparable interface. If this is taken care of, all that is left is to add the `first', `second' and `third' variables to the List when the SortedTrio is created, sort the list and you should be good to go. Make sure that either you don't provide setters for `first', `second' or `third'; if you do, don't forget to sort the list *again* if any of them changes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not sufficient information to troubleshoot the issue I must say. Anyways, is this a compile time or runtime error? You need to paste the exact error you are getting along with the concerned JSP snippet to get appropriate help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not sufficient information to troubleshoot your issue I must say. Anyways, have your tried running the BAT file[startup.bat in BIN folder of Tomcat] rather than starting Tomcat as a service? Does it work that way? Also take a look at the log files [LOGS folder of Tomcat] to find the exact reason why your Tomcat failed to start.