How to pass the value of variable to another java file?

Hi. I have 2 java files (LogonAction.java and PCAction.java). The value of variable(String getrole) depends on the logon user. How can I use this value of variable in PCAction.java? I want to execute a sql statement in PCAction.java which is (String sql="Select * from PP where role"+"='" + getrole + "'") Thanks a lot.
LogonAction.java is below:
package test;
import test.jdbc.util.ConnectionPool;
import java.sql.*
import java.util.*;
import javax.servlet.http.*;
import org.apache.commons.logging.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;
import org.apache.commons.beanutils.PropertyUtils;
public final class LogonAction extends Action {
private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
private ConnectionPool pool;
public LogonAction() {
pool = ConnectionPool.getInstance();
public String getrole;
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
ActionErrors errors = new ActionErrors();
String username = (String)PropertyUtils.getSimpleProperty(form, "username");
String password = (String)PropertyUtils.getSimpleProperty(form, "password");
String getusername=CheckUser(username,password);
getrole=getusername;
java.lang.System.out.println(getrole);
if ("".equals(getusername))
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.password.mismatch"));
getusername=username+getusername;
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.getInputForward());
// Save our logged-in user in the session
HttpSession session = request.getSession();
session.setAttribute(Constants.USER_KEY, getusername);
if (log.isDebugEnabled()) {
log.debug("LogonAction: User '" + username +
"' logged on in session " + session.getId());
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
// Forward control to the specified success URI
return (mapping.findForward("success"));
* Look up the user, throwing an exception to simulate business logic
* rule exceptions.
* @param database Database in which to look up the user
* @param username Username specified on the logon form
* @exception ModuleException if a business logic rule is violated
public String CheckUser(String username,String password){
Connection con = null;
try
con = pool.getConnection();
String sql = "SELECT * from user WHERE userid = ? AND password= ?";
PreparedStatement ps = null;
ResultSet rs = null;
try {
if (con.isClosed()) {
throw new IllegalStateException("error.con.isClosed");
ps = con.prepareStatement(sql);
ps.setString(1,username);
ps.setString(2,password);
rs = ps.executeQuery();
String returnstr="";
while(rs.next())
returnstr=rs.getString("role");
java.lang.System.out.println(returnstr);
return returnstr;
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("error.ps.executeQuery");
} finally {
try {
if (ps != null)
ps.close();
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("error.rs.close");
catch (SQLException e)
e.printStackTrace();
throw new RuntimeException("Unable to get connection.");
finally
try
if (con != null)
con.close();
catch (SQLException e)
throw new RuntimeException(e.getMessage());
}

You can use PreparedStatement and
String cmd = "select * from PP where role=?";
PreparedStatement stmt = conn.prepareStatement(cmd);
stmt.setString(1,theRole);

Similar Messages

  • How to pass the value one portlet to another portlet

    I have one page they are two portlet one portlet html portlet, another one form portlet. i want html portlet value pass to form portlet , is possible pls replay me

    in the tag ACTION of the HTML portlet, or in a HREF tag inside, you just have to put the URL of the same page, but with adding the parameter. (this step in manual because it's a html portlet).
    Then, you declare the parameter at the page definition level (as documented), and finally, you map the page parameter to input parameter of the form portlet. I Hope that Form portlet accepts input parameters. You better Check before.
    Other technique: Use the companion portlet of omniportlet which builds a parameter form. It's suitable for entering value that are propagated to others portlets in a page. And the call back URL is build automatically.
    Patrick.

  • How can i pass the value one from to another form?

    hi all
    how can i pass the value one from to another form  with out use it when ever i want to needed this value that ican useit?
    like i have two fields U_test1 and U_test2  table name @AUSR
    that i have  four form  A! , A2,A3,A4    please tell me in details....?

    Hi,
    U can assign the values to some variables and access then in ur required forms.
    Vasu Natari.

  • In BADi , How to pass the values between two Method

    Hi Experts,
    We have two methods in BADis. How to pass the value  between two Methods. Can you guys explain me out with one example...
    Thanks & Regards,
    Sivakumar S

    Hi Sivakumar!
    Create a function group.
    Define global data (there is a similiar menu point to jump to the top include).
    Create one or two function modules, with which you can read and write the global data.
    In your BADI methods you can access the global data with help of your function modules. It will stay in memory through the whole transaction.
    Regards,
    Christian

  • How to pass the value to "Assignment" when submit the program RFITEMGL?

    Hello friends,
    I want to submit program RFITEMGL  (t-code FBL3N) with some screen fields, some fields are OK to fill such as u201COpen at key dateu201D, u201CG/L accountu201D and u201CCompany codeu201D。 But for the field "Assignment" (It will appear after cilck Dynamic Selection), I don't know how to pass value to it.
    Could you help me about how to pass the value to "Assignment" when submit the program RFITEMGL  (t-code FBL3N) ?
    Thanks a lot!

    Hi,
    Well you can create a small BDC.
    Regards,
    Harsh Bansal

  • How to pass the value from Sub report to main report

    I have un report(mainreport) within a subreport(subreport).
    With reporting services, how to pass the value from Sub report to main report?
    thanks

    Hi Alebet,
    With reporting services to pass values from sub report in to main report is not supported directly.
    But there are some workarounds through which you can get this .
    There are two ways to get this.
    1- Put your sub report query into some table. i mean to say through the subreport query get some temporary table.
    2- Using this temporary tables data write some Scala function in the data base.
    3- Now in your main report query return this scala function as a column.
    4- Extract the column value where ever you want in your main report which is getting calculated from the subreport query. so you will be getting the values returned from the subreport in the main report.
    This will definitely work fine as i have done some report in this way.
    Another way of doing is that
    1- prepare another data set with the same query as in sub report in the data tab.
    2- then refer this 2nd dataset in your main report .
    But better way will be the top one.
    Anyway please let me know if you get the solution.
    Thanks
    Mahasweta

  • How to check the JDK version of a compiled java file

    can anybody tell me how to check the JDK version of a compiled java file ?
    Edited by: gbhatia8 on Sep 9, 2010 7:04 AM

    The major/minor version of the class file is the way to go.
    Also, it's not necessary to write a separate program to get to those. javap prints them out when being passed the -v flag.
    Note, however that "JDK version" is not a correct term, as I can create 1.4-compatible class files with a Java 6 JDK (by passing the -target flag to javac). Those won't look any different than .class files written with a 1.4 JDK.

  • How to pass the values to stored proc using presentation variable in OBIEE

    Need your help regarding in resolving an issue in OBIEE 10.1.3.4.1
    There are 6 reports say ‘A’,’B’,’C’,’D’,’E’,’F’ in the same subject area.
    The reports are being configured with prompts using either the repository/presentation variables.
    One of the reports say ‘A’ has been configured to pass the values using presentation variables from the prompt in Advanced Tab of the report request to the stored procedure defined in the Execute Before Query section of the connection pool.
    After running another report ‘B’ in the same subject area, upon visiting the report ‘A’ view display error is being seen ( Please have a look below screen shot for your reference) .
    Speculate the issue is around presentation variables of report ‘A’ getting initialized even before running the report.
    Appreciate your earliest advise as this is a prod issue.

    Hi Prasad,
    I got your note, you should not use Session variable syntax to call presentation variable.
    you should use like @{AIC_PROJ_PLAT_SEQ_NO}
    One more thing: first test the variable AIC_PROJ_PLAT_SEQ_NO value then try to pass to SP.
    Hope this helps

  • How to pass attribute values through variables in JSP  Custom TagLib

    Hi,
    Can anybody help me how to pass values through varuables in the jsp custom tag.
    i am using JSP custom tag. I am unable to pass attribute values through variables.
    <invitation:invdetails invid="<%=invid%>"/> The value is passing as <%=invid%> ,not value of the invid.
    But i am getting throuh the fllowing
    <invitation:invdetails invid='1' />
    Please anybody suggest me how to pass value by using the variable.

    Hi,
    It sounds like you need to set the <rtexprvalue> tag to true in the TLD for your tag. If you do this the tag will read in the value you are trying to pass to it.
    dapanther...

  • How to pass the values from the Wb Dynpro Application to the SAP Backend ?

    Hi All,
    Good morning..,
    I have scenario like:
    I want to pass the values from the web dynpro appication to the SAP Back end R/3 Table. IN backend the RFC is writtn to accept the structure input from the Webdynpro.
    Upto know I imported the corresponding RFC and maaped to the View.
    How to proceed with the coding to save the data...
    PLease suggest...
    Regards and Thanks in Advance,
    CSP

    Hi  Pradeep
    Steps:
    1. First create an instance for bapi and bind the instance to the bapi node.
      Z<bapi name> zb=new Z<bapi name>();
      wdContext.nodeZ<bapi name>. bind(zb);
    2. Then if u have the import parameter u have to set them by using
        The instance of the above bapi.
        Zb.set<import parameters>;
    3. If the bapi has a table parameters then the structure for the table parameters will also be imported
       In the model class.
    4. Set the table parameters by creating the instance for that structure and using this instance set it.
       Z<Struct>itm tab=new Z<Struct>();
       Tab.set<table parameters>
    5. Then add the structure instance to the bapi instance.
        Zb.add(Tab);
    6. Then Execute the bapi after setting the import parameters.
    7.  If there is any export parameters, then get the values after execution.
    Look at this thread for codes
    Re: RFC call on click of button
    Regards,
    Arun

  • How to pass the value dynamically in exp/imp utilities of oracle

    I want to pass the value of org_grp_i dynamically,instead of passing the value
    19.Can you please tell how to write the script to this
    exp fas/xxxxxx@fasbd001 file=audit_grn_28aug.dmp tables=audit_grn query=\"where org_grp_i=19 \"
    where xxxxxx is the password
    Thanks

    You need to make use of command line arguments. You can go through this link for example.
    http://www.freeos.com/guides/lsst/ch02sec14.html
    In your shell script(say test.sh) you can have
    exp fas/xxxxxx@fasbd001 file=audit_grn_28aug.dmp tables=audit_grn query=\"where org_grp_i=$1 \"$1 indicates it accepts the first argument from command line. if you want to pass 19, add that next to the script you're executing.
    From command line you can call this shell script say test.sh 19

  • How to replace the values in variable selection Screen urgent plz

    Hi all,
    I am having a requirement. where the user need pass the value in the variable, Here v r having option like '1' and '2' which represent 'month' and 'ytd'.
    While selecting user view as 1,2 .Now my requirement is to replace the value 1=monthly and 2=ytd while the user passing the value to avoid the confusion.
    Is it possible if so plz let me know
    Regards

    Dear Venkat.
    You please try the following steps:
    1. Say the InfoObject is 0EMPLOYEE against which you have created the variable, which user is trying to select value against, when they execute the report.
    2. Goto RSA1-> InfoObject tab-> Select InfoObject 0EMPLOYEE.
    3. Selcet the following options:
       Query Execution Filter Val. Selectn  -  'Only Posted Value for Navigation'
       Filter Value Repr. At Query Exec. -      'Selector Box Without Values'
    Please let me know if there is any more issue. Feel free to raise further concern
    Thnx,
    Sukdev K

  • To pass the values through variable in JDBC adapter

    Hello,
    We are working in JDBC adapter. Currently we have written the select statement in JDBC sender adapter to select all the values from the table in SQL SERVER.
    Instead of this, Can we use a variable and pass the values in there from XI in order to select the records from the table based on values in the variable?
    Expecting Advice!
    Thanks,
    Lakshmi.

    Hi krishnan,
    You can use the JDBC receiver adapter to acheive a select using variables. Here you create a canonical XML format(your XSD) based on which the JDBC receiver adapter issues a select and returns you the response. chk this url in help site http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm for the canonical format.
    However u lose the flexibility of polling the table at regular tables available with sender adapter. Also you need an event(a message) to trigger this select query execution, since it is a receiver CC config.
    -Saravana

  • How To pass the value within the page using jsp?

    How to passing the textbox value within the jsp page without using javascript or reload the page.
    I have a scenario like this:
    I have a textbox named as "accno" which allow user to key in the accno. After key in the accno, this accno value will used to do a query from database using jstl.
    here is part of my code
    <input name="accno" type="text" onChange="checkLC()"/>
    <sql:query var="results" dataSource="${db}">
    select accno,name from account where accno = '<%=value get from accno textbox%>'          
    </sql:query>
    <c:out value="${result.rows[0].name}"/>
    note that onChange() is the javascript when user key in accno then automatically go to check database then only show out the name. So how can i get the '<%=value get from accno textbox%>' from accno textbox.

    How to passing the textbox value within the jsp page
    without using javascript or reload the page.No, jsp executes on the remoter server, the text box is on a client machine, you need to send information to the server over the network, http does this with a request, which will reload the page.....................

  • How to pass the value of the return type parameters in teststand sequence file programatically through c#

    I have used the method LoadProtoTypeFromMeteDataToken(tokenvalue,options).with this i cant set the value in the return parameters. How can I pass the value.with the above method it displays parameter Name,Type,In/Out. how can i set the value in the return parameters.

    Or here
    http://forums.ni.com/ni/board/message?board.id=330&thread.id=26979
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

Maybe you are looking for

  • Premiere Pro CC 2014 playback freezing and crashing with new iMac i7

    Using Premiere Pro CC 2014 and having constant playback freezing and software crashes on a brand new iMac i7. Here are the specs: iMac i7 4.0GHz 5k Retina 32 GB Ram AMD Radeon R9 M295X 4GB graphics card 512GB Solid State Drive I was on chat yesterday

  • What is needed to develop web services with DI Server using C #?

    Hi, What is needed to develop web service using DI Service ad C#? Does anyone have any examples? thanks, Willian

  • Windsor Castle Container Issue...

    Has anyone observed this bug with Windsor container, This is a example of the problem that i am facing. Class A Implements Interface I, and both A & I are registered with the container as Singleton. During application Load 'class A' is resolved and s

  • How to see Process Chain Hierarchy

    Dears sirs, I would like to know all the hierarchy chain from a cube or an ODS. Can someone explain how to list all the Process Chain Hierarchy to the top (start) Reagards, Santos,

  • Unable to resolve 'class' or 'interface' expected compile error

    Any help would be appreciated - I can't resolve the following compile errors: E:\j2sdk1.4.0\bin\RandomApp3\src\RandomApp3.java:85: 'class' or 'interface' expected private void initComponents() { E:\j2sdk1.4.0\bin\RandomApp3\src\RandomApp3.java:97: 'c