david allen

Ranch Hand
+ Follow
since Sep 27, 2002
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 david allen

Hi all,
I am running tomcat and using Struts tiles.
In a jsp page I have the following line of code <%=request.getRequestURL() %>
However, it does not return http://mydoamian/mycontext/mypage.jsp it returns
http://mydomain/mycontext/WEB-INF/jsp/template.jsp

Would anyone know why this is?

thank you
david
Hi all,
We have a pagination tag that is responsible for creating links at the bottom of the page for viewing large amount sof records.

The tag is responsible for generating the url's that are written to the page. It uses HttpServletRequest.getContextPath() to retreive the current context. In our development environment this works as expected and returns the correct context. However, in our production environment it returns the following - WEB-INF/jsp/template.jsp. This is not correct. As it works in development I think it must be a configuration setting in the tomcat production server.

Would anyone know of a reason why this would happen and if there is a setting that I need to adjust?

thanks
14 years ago
I am using a JTextArea control whose fonts size is set to 24. For some reason it places quite a large space between the rows of text. It looks to me like the method used to calculate this height could be incorrect. I really want to be able to set that space by self.

It could be that the row height is based on the font but even still the row height that is produced is too big.

Does anyone know how to control the row height in a JTextArea object

Thank you for your help.
David
14 years ago
I have a site that allows a user to select an items to buy. I store these selected items in their session. To actually buy the items they go to a third party site.

The third party site calls a url on my site so I know that the user has purchased and paid for the items. I need to associate the items that were purchased with the user that purchased them so I can update the database

If I append the JsessionId to the url that the thirdparty calls.

i.e. http://mysite.com/processPurchasedItems?JSESSIONID=1234

If this url is used and I call request.getSession() will this find the session for the correct user?

thank you
david
14 years ago
Hi all,
I am able to use EL when it is within a tag i.e.
Name: <c:out value="${name}" />

but if I try and use

Name: ${name}

the jsp simply prints out 'Name: ${name}'

Could someone please tell me if I need to change my configuration. I am using tomcat 5.0
14 years ago
JSP
Hi all,
When I try and attach a file to an email it somehow removes the email body text.If I dont attach the file the body text appears. It must have something to do with how I am using the mMultipart object.

Below is my code. Could someone please show me what I am doing wrong?

// Define messgae
Message message = new MimeMessage(this.session);
Address fromAddress = new InternetAddress(fromEmail, fromName);
message.setFrom(fromAddress);
message.setSubject(subject);

Multipart multiPart = new MimeMultipart();
BodyPart bodyContent = new MimeBodyPart();
bodyContent.setText(this.body);
multiPart.addBodyPart(bodyContent);


// Add Attachment
if (file != null) {
BodyPart attachment = new MimeBodyPart();
attachment.setDataHandler(new DataHandler(new FileDataSource(file.getAbsolutePath())));
attachment.setFileName(file.getName());
multiPart.addBodyPart(attachment);
}

message.setContent(multiPart);

InternetAddress address = new InternetAddress(contact.getEmail().getAddress());
message.setRecipient(Message.RecipientType.TO, address);
Transport.send(message, message.getRecipients(Message.RecipientType.TO));
14 years ago
Thank you for your reply.
Regarding your last solution. When there is an error where do I forward the request to?
15 years ago
Does anyone know of how to configure and set up spring and hibernate. I am using tomcat as well. I would like to know how to configure the xml files i.e. connection pooling.

A tutorial would be great.

thank you
Hi All,

I have an action called CreateNewUserPrepareAction. The jsp has a User form to capture the data. In adition to this, the JSP has a list box whose items are retrieved from the database. The values for the list box are stored as a List in the request as an attribute and are then displayed as part of the form.

When the user submits the form the request gets sent to CreateNewUserAction. I validate the contents using the Validate method. If the user has entered some invalid entry I return to the page displaying an error message. However, the items for the list box are no longer in the request(which is correct). I do not want to store them in the session as I dont think they belong there.

Has anyone come across this problem before and can the recommend some pattern that provides a nice solution. I dont think it is correct either if the Validate method sends a call to the database either.

Thank you
David
15 years ago
I have the following query where I want to add further restrictions to the join join clause. I am using the 'wtih' keyword as in written in the hibernate docs. However, I am always getting the following error a org.hibernate.hql.ast.QuerySyntaxError: unexpected token. If I take out 'with p.deleted is null' it works.

from Category as c
left join fetch c.member
left join fetch c.photos as p with p.deleted is null
where c.id = :categoryId
and c.member.id = :memberId

Does anyone know how to get this working?

thank you
david
After every declaration of an anonymous class are we required to add a semi colon?

Or is it only in some cases?

Thank you
david
The following piece of code creates a run time error at line 2. As we are casting from base to sub (going down the tree) we need a cast. Line 2 has a cast. However if I change line 1 to Base1 base = new Sub() it works. I think I am missing a fundamental understanding of casting.

class Base1 {}
class Sub extends Base1 {}
public class Orange {
public static void main(String args[]) {
Base1 base = new Base1(); // 1
Sub sub = (Sub)base; // 2
}
}
Hi guys,

I really do know this rule and I am very suprised it caught me out. I think it was the fact that it was on the return statement that did it.

thank you
david
The following piece of code prints out "Counter = 0". I just cant figure this out. I thought it would have printed "Counter = 1". Could someone please explain this?


public class A {

private static int counter;

public A() {
System.out.println("Counter = " + getCounter());
}
public static int getCounter(){
return counter++;
}

public static void main(String[] args) {
A a1 = new A();
}
}
What Edisandro wrote is not exactly correct.

>> If you want to make the "i" member accessible through class B, you must either mark "i" as public or default.

Default is more restrictive than protected. You will have to declare "i" as public in this example to get it to compile.