Abhi Basu

Greenhorn
+ Follow
since Apr 05, 2004
Merit badge: grant badges
For More
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 Abhi Basu

Let me answer my own question .... this was solved by putting the contents
of the dropdown in the session, instead of the request.
19 years ago
Hi:

First time trying to use the Validator in Struts 1.1. Secnario
described below:
1. Jsp file contains a search form with dropdown populated from db, and last name and first name fields. I have extended the ValidatorForm class here.

2. Have made sure the struts-config.xml has validator plug-in section uncommented.

3. Updated the validation.xml file appropriately for the form.

4. Made sure resource bundle file has text for the keys defined (for form
elements).

5. Made sure that validation-rules.xml has the rule setup correctly.

Before when I used to perform validation in the form bean, I had code which on some validation error, would query the db and populate the drop
down before forwarding to the page and display the error message.

Where do I do that part now? Now, I do not have a public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) method
call in the form bean anymore? When I run the program now, I get a:
javax.servlet.ServletException: Cannot find bean under name <bean name>,
obviously as the bean is empty.

Thanks.
19 years ago
sbFinal is the StringBuffer with all the data.

BLOB oracleBlob = null;
OutputStream outstream = ((BLOB)oracleBlob).getBinaryOutputStream();
byte[] data = sbFinal.toString().getBytes();
outstream.write(data);
outstream.close();

Is this how to do it for an Oracle blob? Thanks.
[ May 21, 2004: Message edited by: Abhi Basu ]
19 years ago
I want to store the blob into a db table after this is accomplished.

Thanks!
19 years ago
This works now! Thanks, All. After I got the code right, I realized that my Vector was null. :0}
Thanks again, Marc and Sreenath.
19 years ago
Marc:
What that I get:
contact_0005fsearch$jsp.java [221:1] setCollection(java.lang.String) in org.apache.struts.taglib.html.OptionsTag cannot be applied to (java.lang.Object) _jspx_th_html_options_0.setCollection(request.getAttribute("lstCountry"));

BTW, I am dealing with a vector of objects here, hope that's not the
problem. All the examples I see on the web uses ArrayLists .... is that
a coincedence?
Hmm ....
Thanks.

Originally posted by Marc Peabody:
See if this works:
<html ptions collection='<%= request.getAttribute("lstCountry") %>' property="countryId" labelProperty="countryCode"/>


[ May 03, 2004: Message edited by: Abhi Basu ]
19 years ago
Sreenath:
Thanks for your comments. It still does not work even after using this as suggested:
<html:select property="countryId">
<html ptions collection="lstCountry" property="countryId" labelProperty="countryCode"/>
</html:select>
Now, this is what I get:
javax.servlet.ServletException: Cannot find bean under name lstCountry
I do have lstCountry in the request!
[ May 03, 2004: Message edited by: Abhi Basu ]
19 years ago
I am new to Struts and am having problems populating drop-downs from the
database. I am actually getting a little frustrated with these tags,
seems like not coding in java anymore.

1. ActionClass code excerpt:
mBean.makeConnection(); //db connection made thru helper class

//get country list vector
Vector v = (Vector)mBean.getCountryList();

request.setAttribute("lstCountry", v)
2. The vector contains a list of CountryObjects, here's an excerpt
from the CountryObject class:
/* Country ID */
private String country_id;

public String getCountryId() {
return (this.country_id);
}
public void setCountryId(String id) {
this.country_id = id;
}

/* Country Code*/
private String code = null;
public String getCountryCode() {
return (this.code);
}
public void setCountryCode(String code) {
this.code = code ;
}
3. JSP code excerpt:
The vector lstCountry contains CountryObject beans that have getters and setters
for country_id and name.

<html:select property="countryId">
<html ptions collection="lstCountry" property="country_id" labelProperty="name"/>
</html:select>
Any help is greatly appreciated!
Thanks,
Abhi
19 years ago
Thanks! That's what it was, I was closing the tag.
Yeah, I understand about the session comment, I was planning to use
the request anyway, just put that in for testing purposes.
19 years ago
I am trying something very simple. Assume all imports have been done correctly, I will post chunks of the code here.
Summary:
I do not have a form bean in this example. Basically have a link that calls an action findContact action class that makes a connection to an Oracle db using another connection class and executes a stored proc that returns a resultset. I also have a class called ContactObject that holds the props
like contact name, address, country and I stuff values from the recordset
in this object and in turn stuff them inside a vector and put it in the
session so my jsp page can use the vector. (See code excerpts below).

1. I have a jsp file called index.jsp that has a link which does the following:
<p><html:link page="/findContact.do">Find Contacts List</html:link>
--------------------------------------------------------------------------
2. Struts.config file has the following entry:
<action-mappings>
<action path="/findContact"
type="com.paetec.pinnacle.al.GetContactAction"
input="/index.jsp"
scope="request">
<forward name="success" path="/contact_details_struts.jsp" />
<forward name="failure" path="/contact_details_struts.jsp" />
</action>
</action-mappings>
--------------------------------------------------------------------------
3. ContactObject is a simple class with getters and setters for the
contact elements.
--------------------------------------------------------------------------
4. GetContactAction class excerpt:
//CBean makes the db connection and performs the query
cBean.makeConnection();
rs = (ResultSet)cBean.getContacts();

//Convert resultset into vector of contact objects to be passed to the jsp thru request
Vector v = new Vector();

while (rs.next())
{
ContactObject cObj = new ContactObject();
cObj.setFirstName(rs.getString("fname"));
cObj.setLastName(rs.getString("lname"));
cObj.setAddress(rs.getString("email"));
cObj.setCountry(rs.getString("country"));
v.add(cObj);
}

System.out.println("Vector Size = " + v.size());

//Pass recordset to JSP
//request.setAttribute("lsContacts", v);
request.getSession(true).setAttribute("lstContacts", v);
--------------------------------------------------------------------------
5. jsp code excerpt:
<logic:iterate id="c" name="lstContacts" scope="session" type="com.paetec.pinnacle.al.ContactObject"/>
<tr>
<td width="184" bgcolor="white">
<bean:write name="c" property="lastName"/>, <bean:write name="c" property="firstName"/>
</td>
<td width="184" bgcolor="white">
<bean:write name="c" property="country"/>
</td>
<td width="184" bgcolor="white">
<bean:write name="c" property="address"/>
</td>
</tr>
</logic:iterate>
--------------------------------------------------------------------------
I put a debug statement and found out that my vector is being loaded
with 417 elements (each ContactObject). However, the jsp page only
displays the last element from the vector, not all 417 rows!! Any
ideas? Any help is greatly appreciated. I am new to Struts, as you
can say.
Thanks.
19 years ago
The first time it works fine always. This happens either the second time
or third time. I have read that this is a bug in JDK 1.3 and JSSE implementations. This may also be fixed in JDK 1.4. However, I am not
at liberty to upgrade to JDK 1.4. Is there any workarounds to this problem?
I am using NetBeans 3.51, JDK 1.3.1, JSSE 1.0.3_02 in my development enviroment, trying to get to a Remote Dir Server which has a SSL port available for use. This works great when connecting non-SSL. Any help is greatly appreciated. I also don't see anything in the logs when this
occurs. Thanks!
I ran into this problem myself. I fixed this by updating the cacerts file
in the JVM ($JAVA_HOME/jre/lib/security) with the same file from a JDK1.4 installation. Apparently, the JDK 1.4 knows about a lot more licensing
agencies (like Verisign, Thawte etc) than JDK 1.3 ever did. This would
work for all certificates issued by known agencies/common agencies, even test/trial ones. If you use a custom certificate, then you would have to export the certificate out of your server and import it into the JVM of your app server/web server.
Hope this helps.
I ran into this problem myself. I fixed this by updating the cacerts file
in the JVM ($JAVA_HOME/jre/lib/security) with the same file from a JDK1.4 installation. Apparently, the JDK 1.4 knows about a lot more licensing
agencies (like Verisign, Thawte etc) than JDK 1.3 ever did. This would
work for all certificates issued by known agencies/common agencies, even test/trial ones. If you use a custom certificate, then you would have to export the certificate out of your server and import it into the JVM of your app server/web server.
Hope this helps.