J Craig

Greenhorn
+ Follow
since May 04, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by J Craig

For 1 if your cities and countries dont change very often why go to the database to get them,why not just use beans that hold the data. The memory hit will be negligible so you can store in context. Should save time on two trips to database for information that does not change often. I am not versed in javascript so I would use tags.

For 2 I have a project that uses this very technique. You set some variable that when true indicates you should include a page. The page to be included will be looking for the values of beans or variables from the page doing the including to display the results of the query,nothing wrong with that.
[ November 04, 2004: Message edited by: J Craig ]
20 years ago
When using javamail with struts framework can you send mail from action class or does it have to be from servlet.
20 years ago
Can anyone present and example of using the tomcat javamail utility in jbuilder x or supported versions. If no example can anyone provide link to documentation.

Many thanks in advance
J.C.J
Currently I am using html:link to pass control to another jsp page. I would like to have the control first pass through the controller servlet before sending to resource. I don't want to use a form would prefer using the link is there any way to code this so that the link passes control to action class or controller for forwarding.

Any help appreciated
Jeff
20 years ago
Can someone please tell me how to configure tomcat for use of Datasource.
If you could provide a basic step by step?

thanks in advance
J.Craig
20 years ago
I am trying to test displaying errors in my jsp page but my result is this
???en_US.error.username???
???en_US.error.password???displayed instead of the info from properties file any help would be welcomed


my properties file is
ApplicationResources
# -- errors --
errors.username=<member>Please enter user name.</member>
errors.password=<member>Please enter pass word.</member>

RegisterActionForm
package strutproject;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;


public class RegisterActionForm extends ActionForm {
private String password;
private String username;
private RegisterActionForm form;
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ( (username == null) || (username.length() < 1))
errors.add("username",
new ActionError("error.username"));
if ( (password == null) || (password.length() < 1))
errors.add("password",
new ActionError("error.password"));


return errors;
}
}
strut-config
<struts-config>
<form-beans>
<form-bean name="registerActionForm" type="strutproject.RegisterActionForm">
<display-name>RegisterActionForm</display-name>
<description>Populated with fields from Register.jsp checks to make sure both fields have values.</description>
</form-bean>
</form-beans>
<action-mappings>
<action input="/Register.jsp" name="registerActionForm" path="/registerAction" scope="request" type="strutproject.RegisterAction" unknown="false" validate="true">
<forward contextRelative="true" name="success" path="/Success.jsp" redirect="no" />
<forward contextRelative="true" name="fail" path="/Fail.jsp" redirect="no" />
</action>
</action-mappings>
<message-resources null="false" parameter="ApplicationResources" />
</struts-config>

relevant web.xml
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
20 years ago
When using a datasource is it best to have one class that does all database access or is it best to have a seperate object for each type of request to database(update,delete,etc).
Hello is there any restriction in where you can access your datasource?
I mean does it have to be from servlet or jsp or can any class access it?
Given a result set or collection can anyone help in implementing a next page previous page functionality.
Should be able to list a set amount of records that will be viewed and if you get real fancy indicate how many pages are present basically the same as this site uses
20 years ago
Thanks Jeff I do have a singleton class in which all database access is done
will using the connection pool as a member of this class suffice.
posted May 04, 2004 06:12 AM
--------------------------------------------------------------------------------
Can I pass any kind of parameter to a callable statement? I have a set of values which I want to store in a vector and get them processed through a stored procedure and I want this stored procedure to return a collection. Is this possible? or can I only send string, int, float and other primary datatypes?
Also, can I have this callable statement valid across multiple databases? like oracle, SQLserver, db2 etc? Do I need to take any precautions?
Thanks,
Padma.
The stored procedure wil not accept a vector you can create a method that iterates through the vector calling the statement for the each value
I know you probably wanted your database to do most of the processing but I dont' think you can use any data structures as parameters to stored procedures.
The result set can be stored in a data structure as far as the sql you just need to check syntax I believe at least sql server and oracle are slightly different.
Repost wrong forum sorry
--------------------------------------------------------------------------------
I have a question about when to initialize the connection pool currently I am using a class for connection pooling and it is not performing correctly because multiple instances are being created. I am using a mvc approach and only have one servlet into the webApp. Can anyone tell me where I should initialize the connection pool object In the case of JNDI and a datasources I pose the same question How do I make sure there is only one reference so that pooling works correctly
My design is (jsp/html)TO controllerServlet(decide where to go instantiate helper class using command pattern) TO helperObject(performs specific task inserts updates deletes,etc as well as passing back to the controllerServlet the next jsp/html page to be forwarded to).

--------------------------------------------------------------------------------
1- useBean to populate my FORM
use form to populate bean:you can do in servlet or jsp in jsp just use <jsp:usebean ID="myBeanInstance" CLASS="com.myPackage.myBeanClass" SCOPE="request">
<jsp:setProperty NAME="myBeanInstance" PROPERTY="myProperty"
PARAM="myFormElementName"/>
</jsp:usebean>
In servlet instantiate bean set properties with request.getParameter("name of param from form);
2- Modify the data
Not really sure what you want but you can put a reference to your bean in the session or request by using setAttribute method
this makes it available in session or request with getAttribute method
3- set the new bean property to send to the servlet
unclear here also but if you want to get a reference to the bean getAttribute method will do make sure you cast back to bean
if you are just talking about making the bean available to the servlet you would need to use setAttribute method of request or session in jsp form
4- processing
no clue what you mean
5- forward somewhere else the updated bean
the bean is available anywhere you have a reference to the request or session. So you are not forwarding but getting the bean from a particular scope cast and use if you still need it put it back in the request or session.
I have a question about when to initialize the connection pool currently I am using a class for connection pooling and it is not performing correctly because multiple instances are being created. I am using a mvc approach and only have one servlet into the webApp. Can anyone tell me where I should initialize the connection pool object In the case of JNDI and a datasources I pose the same question How do I make sure there is only one reference so that pooling works correctly
My design is (jsp/html)TO controllerServlet(decide where to go instantiate helper class using command pattern) TO helperObject(performs specific task inserts updates deletes,etc as well as passing back to the controllerServlet the next jsp/html page to be forwarded to).
You must first obtain reference to the ServletConfig could do: cntxRef=configRef.getServletContext and then cntx.getAttribute("attName")
you of course can also use to set the variable.