Rahul Dhamecha

Greenhorn
+ Follow
since Mar 13, 2012
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 Rahul Dhamecha

Tim Moores wrote:What do you mean by "confidential id"? From who are you trying to hide it, and why? Note that POST parameters are as much open to inspection as GET parameters, they're just not part in the URL.



By confidential I mean, I don't want them to be seen in the url. These values are the primary values stored in my database for each of the enlisted items.

12 years ago

Shankar Tanikella wrote:Hi, Genuinely submit the form i.e. set these values in the form using onClick javascript method call which submits the values and retrieve the same in action.



These values are not to be obtained from the user. I am printing a list of items, where in each item is associated with a unique Id which is confidential. Each list is also a link in itself; so when I click on this link I am redirected to the next page depending on the confidential id I want to pass. I have used the html:link struts tag to create a link. I want to pass that confidential id upon every click.

How should I set the values in the javascript? Won't these values be treated as plain javascript variables and will not be passed on the form submit?
If possible please provide a code, I am unable to find a solution to the above
12 years ago
Hi, I have a jsp file wherein I am iterating a list of Strings.
Each String by itself is a hyperlink which when clicked invokes a method in an action class.

I want to transfer the value of the String clicked from the jsp page to the action class without showing the value in the address bar. I am aware that using html:link enables me to transfer the parameter to the action class but it shows in the address bar.

I also tried using a scriptlet and used request.setAttribute() method to set the value of an attribute but when I retrieve the same in the action class using request.getAttribute() I encounter a NULL

How should I achieve my objective.
12 years ago
Also, below is the VO or DTO AccountDetails class

import java.io.Serializable;

public class AccountDetails implements Serializable{

/**
*
*/
private static final long serialVersionUID = 1L;
private String accountId;
private String accountHolderName;
private String accountType;
private String accountBalance;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccountHolderName() {
return accountHolderName;
}
public void setAccountHolderName(String accountHolderName) {
this.accountHolderName = accountHolderName;
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public String getAccountBalance() {
return accountBalance;
}
public void setAccountBalance(String accountBalance) {
this.accountBalance = accountBalance;
}

}

I have made a list of objects of the above class.
12 years ago
Forgot to give the entries of both the action and form bean in the struts config file.

<struts-config>
<form-beans>
<form-bean name="loginPage" type="form.userLogin.UserLoginForm"></form-bean>
<form-bean name="viewDetails" type="form.userLogin.ViewAccountDetailsForm"></form-bean>
</form-beans>

<global-forwards>
<forward name="sessionexpired" path="sessionExpired.jsp"></forward>
</global-forwards>

<action-mappings>

<action path="/userLogin" type="userlogin.UserLoginValidation" name="loginPage"
validate="false" parameter="function">
</action>

<action path="/viewAccountDetails" type="userlogin.ViewAccountDetailsAction" name="viewDetails"
validate="false" parameter="function">
<forward name="launch" path="/viewAccountDetailsPage.jsp"></forward>
</action>

</action-mappings>
</struts-config>
12 years ago
Hi,
I have a page called index.jsp that takes the username and password.
The form is submitted to a servlet that verifies the username and password. If they are valid, I use a sendRedirect to redirect the request to an action(ViewAccountDetailsAction) inside my Struts 1.3 application.

I am using the ViewAccountDetailsForm class as my ActionForm. This has been associated with the above action class in the struts-config.xml file.

ViewAccountDetailsForm.java

import java.util.List;
import org.apache.struts.action.ActionForm;
import pojos.login.AccountDetails;
public class ViewAccountDetailsForm extends ActionForm {
private static final long serialVersionUID = 1L;
private List<AccountDetails> accountsList;

public List<AccountDetails> getAccountsList() {
return accountsList;
}
public void setAccountsList(List<AccountDetails> accountsList) {
this.accountsList = accountsList;
System.out.println("This is the size of accountList of ViewAccountDetailsForm "+this.accountsList.size());
}
}


ViewAccountDetailsAction.java method inside which the account details are gathered.

import interfaces.login.ViewAccountDetailsInterface;

public ActionForward viewDtls(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
//check for SessionActivity
HttpSession session = request.getSession();
if(null!=session){
if(null!=session.getAttribute("username")){
System.out.println("OSR");
System.out.println(session.getAttribute("username").toString());
ViewAccountDetailsForm viewAcctDtlForm = (ViewAccountDetailsForm) form;
ViewAccountDetailsInterface viewAccountDetails = new ViewAccountDetailsBean();
viewAcctDtlForm.setAccountsList(viewAccountDetails.getAccountDetails
(session.getAttribute("username").toString()));
return mapping.findForward("launch");
}
else
return mapping.findForward("sessionexpired");
}
else
return mapping.findForward("sessionexpired");
}

launch.jsp - file on which all my account details must be displayed

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<logic:empty name="ViewAccountDetailsForm" property="accountsList">
The accountsList is empty
</logic:empty>
<logic:present name="ViewAccountDetailsForm" property="accountsList">
<%out.write("OSR: Present cleared"); %>
<table border="1px" bordercolor="blue">
<tr>
<td>Account Number</td>
<td>Account Balance</td>
</tr>
<logic:iterate id="accountDetail" name="ViewAccountDetailsForm" property="accountsList">
<tr>
<td><bean:write name="accountDetail.accountId"/></td>
<td><bean:write name="accountDetail.accountBalance"/></td>
</tr>
</logic:iterate>
</table>
</logic:present>
<%out.write("Outside write"); %>
</body>
</html>


Problem:
I am getting Can't find ViewAccountDetailsForm bean in any scope

Can someone suggest a work around?
12 years ago
Hi, thanks for your replies.

The problem was with the jsp:include! Instead of using that I used the include directive. Apparently the former returns the result of the resultant servlet and embeds it in the index2.jsp file. However, include directive works differently.

However, as paul pointed out I am going to keep the session Management code in a servlet which results to a better design.

Thanks again.
12 years ago
JSP
Hi,
I have a file named index2.jsp given below:




The sessionManagement.jsp file is as given below:




Problem:
Prior to hitting the index2.jsp page I have created a session in a servlet and set the MaxInterval value to 15(seconds) using the inbuilt setMaxInterval... function. Thereafter I use a sendRedirect to get to index.jsp page.
The index.jsp that contains a link pointing to index2.jsp. When I click it after 15seconds my response.sendRedirect("/sessionExpired.jsp") doesn't go to sessionExpired.jsp but prints only OSR(content of index2.jsp) on the index2.jsp page.

I don't want it to go to index2.jsp page if the session becomes invalid. I want it to redirect to sessionExpired.jsp instead. How should I do this?
12 years ago
JSP