Thomas Byrne

Greenhorn
+ Follow
since Aug 21, 2012
Thomas likes ...
Mac OS X Netbeans IDE Tomcat Server
Merit badge: grant badges
For More
AU
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thomas Byrne

Hi fellows,

I'm a bit lost with following scenario:

1. user upload image - upload.jsp
2. servlet do all dirty job
2a. save image to disk
2b. get name of the file
2c. save the name in session
2d. and redirect to display.jsp)
3. on the display.jsp, just uploaded image should be presented.

Unfortunately the display.jsp page is empty. When I look at source page under firefox, everything seems to be fine, valid link to the image is provided.

But under Media info I can see some weird infos:

Here is code used for uploading, processing and displaying picture:
1. upload.jsp

2. Upload.java
(The MultipartMap servlet belongs to BalusC, http://balusc.blogspot.com.au/2009/12/uploading-files-in-servlet-30.html)

3. display.jsp

If I replace, in display.jsp, ${filename} with static name of the particular image uploaded before, there is no problem with displaying so I suppose the images are processed correctly just something is missing on forward side?

By the way: when debugger is active everything is OK but when switch off the problem is back.

Cheers,
Thomas
11 years ago

Paul Clapham wrote:But that's because in the code you posted, the timestamp values don't have any format at all. A Date, or a Timestamp, is essentially just a number which represents the number of milliseconds



But in this case, in the mysql table, column type is datetime not timestamp. So here, before is written to object I can see how its formatted. And even then I cannot format it?
Cheers,
Thomas
11 years ago
Hi fellows,

If I'm using code like one below to retrieve data from mysql, is there any way to convert, in the same time (inside the loop), the datetime from mysql to shorter format?
Long: Sep 18, 2012 5:24:12 PM --> to short: 18-09-2012 5:24 PM

Cheers,
Thomas
11 years ago
Thank you for remind me that we have something like source viewer in the browser. The key issue were missing quotations mark around ${message.errorID}.
So, working code looks like:

Cheers,
Thomas
Hi fellows,
I'm trying to use the following code to show a div based on the value returned by servlet (${message.errorID}). I can't get this to work and wonder if there is an other/better way?

Cheers,
Thomas
Hi fellows,

Yogesh Lonkar wrote:Well i am certain that it should allow you to get firstName attribute back from session. because i have compiled your project personaly on my workspace and it work here. may be clean and build will do


My apologies, It works if I remove line 28 from Controller.java.
But there is another hiccup with messages. I added some simple validation to the text box, like:

Registration.jsp:
Controller.java:
Regex.java:
After return to the page from Confirm.jsp, even if text box has been filled with correct value, there is always active error message (<span class="error">${message.errorFirstName}</span>).
Any suggestion how to get rid off from that?

Cheers,
Thomas
11 years ago
Hi fellows,

Thank you again, I tried but I'm afraid it doesn't work like that.

Yogesh Lonkar wrote:


11 years ago
Hi fellows,

Thank you bud, but as I said before, I know how to do that with hidden field but the goal is session. I'm pretty sure this is possible although more complicatet than hidden field.

Cheers,
Thomas
11 years ago
Hi fellows,

The problem is how to access, from Registration.jsp page using the EL statements, the data that was entered by the user and saved as a object to the session.
After registration, there is no problem with Confirmation page, the data are displayed, but when the user decide to return to Registration.jsp page to edit data, the text box is empty.
I know how to do that with the hidden fields but my goal is to use sessions.

Lets start with code:
Controller.java

User.java:

Registration.jsp:

Confirm.jsp:


Cheers,
Thomas
11 years ago

Bear Bibeault wrote:A book from 2001 is worse than useless. It'll fill your head with all sorts of trash that's no longer true.


Thats true. I bought today a quite modern books about the subject, Murach's Java Servlets and JSP, 2nd Ed., by Mike Murach & Associates (2008) and
Guide to Web Development with Java: Understanding Website Creation, 2nd by Tim Downey (2012). Now, I can see see difference.
I'm gonna rewrite everything from scratch.

Thank you for your time and support.

Cheers,
Thomas
11 years ago
Hi fellows,

Thank you for your help.

Bear Bibeault wrote:Nope. Not needed. It's completely superflous. The El deals with scoped variables, not scripting variables (which are defunct as of 2002).


You see, this is what happen if you read book from 2001 (Callaway, DR 2001, Inside servlets: Server-side programming for the Java platform, 2nd edn, Addison Wesley, Boston, MA.) That wasn't my choice, the Uni recommended this book for the course.

How I can do that in proper way?

So you are saying that ${(stheatre eq "Oh yes!")} evaluates to true? Have you verified this?


Now I'm a bit confused because it work so I supposed it is OK, but obviously it's not?

Cheers,
Thomas
11 years ago

Bear Bibeault wrote:And I just noticed this on your submit button: onclick="location.href='form.jsp'"What on earth is that doing there? The only purpose for a submit button is to submit the form. What are you trying to accomplish with the click handler?



I don't like it too, so for sure I will try to eliminate that.

Cheers,
Thomas
11 years ago
Hi fellows,
Looks like this made my day. After that everything works like expected (expected by me only).

Seetharaman Venkatasamy wrote:so that control flow will not come.


I know guys that my coding style is far away to be even only good enough but I'm just at the beginning of my path so I'm open for any suggestions.
Cheers,
Thomas
11 years ago
Hi fellows,
Thanks for you help.

Bear Bibeault wrote:A couple of things:
<% String stheatre = (String) session.getAttribute("stheatre"); %>
Why is it there?


For this?

Your page-relative action:
<form action="validator"
is a bug waiting to happen. Use server-relative URLs that start with the context path.


I'm just beginner and so far this is only way I know so forgive me my ignorance.

Debugging: Rather than just seeing if the checkbox is checked, have you verified what the exact value of stheatre is on the second run?


By observing I mean printing session attributes on screen by:Cheers,
Thomas
11 years ago
Hi fellows,

Thank you for your suggestion but so far no luck. Still something is wrong because as far as I stay on the same page (form.jsp) I can see that session attribute for theatre changes according to the checkbox. But, as soon as I left this page and move to the next page confirm.jsp and on this page (still can see that everything with checkbox is OK) press button "Edit" to come back to form.jsp page to start all over again, the checkbox on the form.jsp is unchecked again. Shouldn't be checked if the last time was selected?
What I did:

form.jsp:
validator:

Cheers,
Thomas
11 years ago