Probelm in Sending Parameters/Attributes in JSP

I have the following two file and i want to send parameters for index.jsp to middle.jsp and print them. But when i run the files there print "null" value at <%= request.getAttribute("myparameter")%> in midle.jsp.
Index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hi, I am Zaid from Karachi and My hobby is Cricket</h1>
<h1>Whats Your Name, Hobby and where you belong</h1>
<form method="GET" action="middle.jsp">
<input type="text" name="username" size="25">
<input type="text" name="hobby" size="25"><p></p>
<input type="text" name="city" size="25"><p></p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
<%
request.setAttribute("myparameter", "Passion");
%>
</body>
</html>
middle.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World---!</h1>
<%= request.getAttribute("myparameter")%>
<%= request.getParameter("username")%>
</body>
</html>

Consider the lifecycle.
You request page "index.jsp" It runs index.jsp and produces html. It sets the request attribute "myparameter"
You request page middle.jsp. It runs middle.jsp.
Note that this progression requires two seperate requests - one for "index.jsp" and then another for "middle.jsp", which sends the request parameters from the form from your browser to middle.jsp.
Request attributes only last the life of one request - so when you request "middle.jsp" the request attribute set when running "index.jsp" is not available.
cheers,
evnafets

Similar Messages

  • How to exchange information(parameters) between servlets & jsps

    with an examle if possible.

    Hi
    Exchanging parameters/objects between JSP and Servlets is done by creating an Object and placing it in the ServletContext , User Session or the Request depending on whether the Object requires Application Wide scope, Session Scope or Request Scope respectively.
    If the object is created in the Servlet then it can shared by placing it in either Context, Session or Request through the setAttribute method and similarly retrieved through the getAttribute method.
    For JSP use the <jsp:useBean> tag to retrieve/create the Object (bean).
    For eaxmples see the following Links:
    http://java.sun.com/docs/books/tutorial/servlets/communication/attributes.html
    http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html#JSPIntro11
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems
    http://www.sun.com/developers/support

  • DisplayTag - sending parameters

    Hi guys.
    I�m trying to send two parameters to another jsp by a link in my display:table but Im getting the following error:
    [LookupUtil] Exception: [.LookupUtil] Error looking up property "id,nome" in object type "com.reveng.Client". Cause: Unknown property 'id,nome'
    java.lang.NoSuchMethodException: Unknown property 'id,nome'
    here the code:
    <ww:set name="list" value="listCostumers" scope="request"/>
    <display:table name="lista" requestURI="myAction.action" export="true">
    <display:column property="id" title="Id" paramId="id,name" paramProperty="id,name" href = "Edit.action"/>
    <display:column property="name" title="Name" paramId="id,name" paramProperty="id,name" href = "Edit.action"/>
    </display:table>
    Can I send two parameters in my property name?
    If I can't, how could I catch this two parameters (id and name) in my action Edit?
    Thanks a lot!

    You can tray instead using of & try using &amp;
    hope that helps

  • HTTPService sending parameters

    Hi,
    I am looking for a way to send in a list of parameters to my
    JSP. I already know how to use <mx:Request> tag, but it only
    allows for a predefined number of parameters (at design time). What
    i want to do is to send in an x number of parameters in, basically,
    send in an XMLList contents as parameter list.
    The documentation on HTTPService has a method xmlEncode() and
    xmlDecode(). I could not get it to work and there aren't any
    working examples out there. I guess i could serialize an XMLList
    into a xml string myself and send it as one parameter field and
    then parse it in jsp... or use JSON.
    Is there a workable design pattern for sending complex
    objects in?
    If i was to use HTTPService in ActionScript, theoretically i
    could dynamically add parameters to the Request object. I just
    don't know how to create and use HTTPService fom AS... can someone
    show me? is it hs:HTTPService = new HTTPService();
    hs.request.add("key", "value"); ??
    Thanks for any help.

    I personaly don't agree what they do in that example you
    showed (
    http://www.adobe.com/devnet/flex/articles/complex_data_02.html),
    that is way too much extra unnecessary fanciness that adds
    additional layer of logic on both sides, flex and jsp,which does
    not really give any justifiable FLEXIbility to developer
    why would you want to generate xml then on server side parse
    xml when you can just as easily build request parametes on flex
    side iteratively and same thing on jsp (with existing servler/jsp
    API ) Exaple : iterate through all or partial request parameters
    with code something like this :
    for (java.util.Enumeration e = request.getParameterNames();
    e.hasMoreElements() ;) {
    String name = (String) e.nextElement();
    String value = request.getParameter(name);

  • TRYING TO SEND AN EMAIL VIA JSP not working

    I think what im doing is right but i keep getting errors...therefore...its wrong..
    <form action="mailer.jsp" method="post">
         To :<br>
         <input type="text" name="to" class="std"></input><br>
         From :<br>
         <input type="text" name="from" class="std"></input><br>
         Subject :<br>
         <input type="text" name="subject" class="std"></input><br>
         Message :<br>
         <textarea rows="10" cols="80" name="message"></textarea>
         <br>
         <input type="submit" value="Send"></input>
         </form>Mailer.jsp
    <div class="frame">
         <jsp:useBean id="mailer" class="com.stardeveloper.bean.test.MailerBean">
              <jsp:setProperty name="mailer" property="*"/>
              <% mailer.sendMail(); %>
         </jsp:useBean>
         Email has been sent successfully.
         </div>MailerBean.java
    package com.stardeveloper.bean.test;
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.event.*;
    import javax.mail.internet.*;
    public final class MailerBean extends Object implements Serializable {
         /* Bean Properties */
         private String to = null;
         private String from = null;
         private String subject = null;
         private String message = null;
         public static Properties props = null;
         public static Session session = null;
         static {
              /*     Setting Properties for STMP host */
              props = System.getProperties();
              props.put("mail.smtp.host", "mail.brunel.ac.uk");
              session = Session.getDefaultInstance(props, null);
         /* Setter Methods */
         public void setTo(String to) {
              this.to = to;
         public void setFrom(String from) {
              this.from = from;
         public void setSubject(String subject) {
              this.subject = subject;
         public void setMessage(String message) {
              this.message = message;
         /* Sends Email */
         public void sendMail() throws Exception {
              if(!this.everythingIsSet())
                   throw new Exception("Could not send email.");
              try {
                   MimeMessage message = new MimeMessage(session);
                   message.setRecipient(Message.RecipientType.TO,
                        new InternetAddress(this.to));
                   message.setFrom(new InternetAddress(this.from));
                   message.setSubject(this.subject);
                   message.setText(this.message);
                   Transport.send(message);
              } catch (MessagingException e) {
                   throw new Exception(e.getMessage());
         /* Checks whether all properties have been set or not */
         private boolean everythingIsSet() {
              if((this.to == null) || (this.from == null) ||
                 (this.subject == null) || (this.message == null))
                   return false;
              if((this.to.indexOf("@") == -1) ||
                   (this.to.indexOf(".") == -1))
                   return false;
              if((this.from.indexOf("@") == -1) ||
                   (this.from.indexOf(".") == -1))
                   return false;
              return true;
    }

    I think what im doing is right but i keep getting
    errors...therefore...its wrong..i don't see any errors posted, so it must not be wrongThe error occurs because the OP did not use BSD-style braces.

  • Sending parameters to reports by using Run_Report_Object

    Hi All,
    How do I send parameters to report while using Run_Report_Object built-in ?
    Thanks in advance.
    Regards,
    Sanjay Kanakath

    hello,
    there is a builtin for setting the parameters :
    from the forms builder online help :
    DECLARE
         repid REPORT_OBJECT;
         report_prop VARCHAR2(20);
    BEGIN
         repid := find_report_object('report4');
         SET_REPORT_OBJECT_PROPERTY(repid, REPORT_EXECUTION_MODE, BATCH);
         SET_REPORT_OBJECT_PROPERTY(repid, REPORT_COMM_MODE, SYNCHRONOUS);
         SET_REPORT_OBJECT_PROPERTY(repid, REPORT_DESTYPE, FILE);
    END;
    you can use      
    SET_REPORT_OBJECT_PROPERTY(repid,
    REPORT_OTHER,
    'deptno=10');
    to set the Other Parameters property of the report object.
    regards,
    philipp

  • How to send an email in jsp

    hei evryone!
    can anyone pls help me on how to send an email in jsp. I mean i have a webpage wherein you submit data , upon submission or after the submit button is clicked i need to send an email to a person regarding the data sumitted on the form , i dunno how to do this, can anyone please help me on how to use Javamail, or can anyone post a sample code or site of a tutorial .. thx!

    There are some quite good examples on the use of Javamail on the Sun website. No, we're not going to write your application for you, unless you're willing to pay consultancy fees in real money.
    http://java.sun.com/products/javamail/index.jsp
    http://java.sun.com/products/javamail/FAQ.html
    http://java.sun.com/products/javamail/reference/techart/index.html

  • Problem with boolean attribute of JSP tag

    Hi,
    I've being trying to use a custom JSP tag, which has a boolean attribute, declared in the TLD as follows:
    <attribute>
    <name>checked</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>boolean</type>
    </attribute>
    The JSP code snippet is:
    <ui:check checked="<%= myBean.isChecked() %>"/>
    where myBean.isChecked() returns a boolean value (primitive type).
    It works fine on some web containers, but it causes a JSP compilation error on Oracle9iAS 9.0.3 Java Edition, which looks like the following:
    Method toBoolean(boolean) not found in class test. _jsp_taghandler_57.setChecked( OracleJspRuntime.toBooleanObject( toBoolean( myBean.isChecked())));
    After decompiling the container's JSP parser, I found what I think it's a bug. The java class generated by the JSP parser does not define a toBoolean method, and neither do its superclasses. The method is defined on the OracleJspRuntime class! I think the correct code would have to be something like:
    OracleJspRuntime.toBooleanObject(OracleJspRuntime.toBoolean(...))
    If I'm correct, then the "convertExpression" method of the "oracle.jsp.parse.JspUtils" class must be changed, because it outputs such wrong code for not just boolean types, but for all the primitive types.
    So, has anyone ever faced this problem before? Does it have a workaround, or a patch? Is it included on the bug fixes for the 9.0.4 release?
    Thanks!

    Instead of:
    out.println("<body onload ="+strAlert+">");
    Try this:
    out.println("<body onload =\""+strAlert+\"">");
    Add two \" around the alert call.

  • Calling portal v2 pages with parameters in a jsp

         Hello everybody,
         I'm currently trying to create, in a jsp, a link to a portal-v2 page with parameters.
    Practically :
    [JSP / Portlet 1]
         - a 1st jsp generates some links, all to the same page but each sets a different value to a parameter (for example a productId in a list).
    [JSP / Portlet 2]
         - a 2nd jsp gets this parameter and use it (for example it displays the details of the chosen product).
    So the 1st portlet would be jsp (coded by a portlet designer) and clicking a link would lead to another page (chosen by a page designer) which would hold the 2nd portlet (= 2nd jsp, coded by the same portlet designer).
         Writing the second jsp is easy : getting parameters is described in many examples and pdk articles.
         But I can't find the java methods to use to generate the link. More precisely I don't know how to call the portal page (which would then be a jsp1's parameter). Adding the parameter is well described in the jpdk API-Doc.
         I've tried to use portal events but they seem to work only in an html form. So I supposed it was a wrong way.
    As I've lost myself so many times in the API-Doc and I didn't find any jpdk sample about that, I would be really thankfull if someone has an idea (may I hope for a sample code ? :-)
    Thanks.
    Jean-Roch

    I'm having a similar problem!
    I have a JSP page which I have published as a portlet to Portal. The JSP portlet is placed on Portal a page. I need to call this Portal page with some parameters in the URL, which should get passed to the JSP portlet.
    In the JSP portlet I used this syntax in release 1 to retrieve the URL parameters:
    String p_itemID = request.getParameter("item_id");
    That worked great in release 1, but not in release 2.... I think the problem is that you need to define which parameters a portlet has, then map those portlet parameters to page parameters in the page properties. In dynamic page - portlets you define bind variables to accomplish this. But how do you do in JSP portlets? When you try to map Page Parameters to the JSP portlet you'll find that Portal doesn't think that the JSP portlet has any parameters. Hence the page parameters does not get passed to the portlet.
    (More info: JDBC----getImportedKeys() )
    I've looked at the Multipage example and the forminput example. But I don't see how pass a parameter in the URL to the very first JSP portlet from looking at those examples. I do see how you can pass parameters to the next JSP portlet, but that's not my problem. Maybe I'm missing something obvious...
    Any ideas?

  • Passing Parameters to a JSP

    Hello,
    I have the following problem and would highly appreciate any ideas or suggestions...
    I want to create an iView that contains contents of an external JSP. I have tried creating either a URL iView or an AppIntegrator iView that link to http://SomeServer:8080/Rental.jsp
    Now my problem is passing custom parameters to this jsp. For example I would like the user to select what Color car he/she wants to rent from a drop down list. This list will be a custom property created in the portalapp.xml file and I will set this property to be cuztomizable by the user. If the user chooses "Red" then I would like the iView to refresh pointing to http://SomeServer:8080/Rental.jsp?color=red
    I know how to define custom properties of an iView but I dont know how to set the URL of an iView based on the parameter chosen by the user.
    Thanks,
    Roaa

    You can pass parameters between JSP's using Enterprise Portal Client Framework(EPCF). The following link could be useful to you.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/771fa290-0201-0010-3d93-865e66cc6d7e
    Regards,
    Vijai Mohan

  • Sending emails from the JSP application

    hi,
    I am trying to send emails from my jsp application using JavaMail API's.
    I am using my own mailserver.
    Iam able to send emails from my applications to the ids of my own mailserver but not the yahoo,gmail and rediff ids.
    Is it because of blocking of any firewall or somthing else to do within my application?
    Can anyone help me in this?
    Thanks a lot.

    Please read the JavaMail FAQ.
    It's probably due to the configuration of your mail server,
    which is refusing to relay your messages.

  • How to make a link in textflow that send parameters to a function?

    How to make a link in textflow that send parameters to a function?

    In the examples included with the weekly builds there is a CustomLinkEventHandler.as example.  Passing parameters would be done in the CustomClickHandler function.  You could attach the parameters to the LinkElement as user styles using the setStyle API.
    Hope that helps,
    Richard

  • URLConnection problems(Sending parameters with URL)

    Guys i have some problems with sending parameters through URL using URLConnection class.
    That's my code:
    URL url = new URL("http://kiosk.homebank.kz:9090/default.asp?action=SaveContact&src=C_HOMEBANK&ClientId="+request.getParameter("ClientId")+
                        "&IdService="+request.getParameter("IdService")+
                        "&Contact="+URLEncoder.encode(request.getParameter("Contact"),"utf-8")+
                        "&Number="+URLEncoder.encode(request.getParameter("Number"),"utf-8")+
                        "&Work="+URLEncoder.encode(request.getParameter("Work"),"utf-8")+
                        "&Mobile="+URLEncoder.encode(request.getParameter("Mobile"),"utf-8"));
            URLConnection connection = url.openConnection();
            connection.setDoInput(true);
            connection.setDoOutput(true);I want just send these parameters without going to this link. How can i do it using URLConnection class? Help please!

    Try using this set method in the URL class (query is the parameters):
    protected void set(String protocol,
    String host,
    int port,
    String authority,
    String userInfo,
    String path,
    String query,
    String ref)

  • How come property attribute of jsp:getProperty  knows which method to call

    Hello friends,
    I could not understand How come property attribute of <jsp:getProperty knows which method to call
    <jsp:useBean id="test" class="BeanTest.testing" scope="page" />
    <jsp:getProperty name="test" property="name" />
    there is no method "name" in testing.class file
    if u see the existing examples "date" given in TOMCAT , it is using many <jsp:getProperty tag, but the property name is not equal to the method method name in the Bean file
    thanks,

    First do you know what a
    bean property sheet is?
    If not say so.
    Second, to your question
    The Java Runtime Environment (JRE) uses introspection to identify the appropriate get() or set() methods of that bean. What is introspection?
    Introspection is a process that allows the class to expose its accessable variables and methods and allows other classes to see what they can do with that class when requested. Eg:
    public class MyBean{
    private String someValue = null;
    public MyBean(){
    someValue = "Some String Value";
    //Introspection will reveal this method
    public String getSomeValue(){
    return someValue;
    } and
    <jsp:getProperty name="...." property="someValue" />
    will call the getSomeValue() method

  • Sending an email through JSP and WML

    I am trying to send an email through jsp in wml, i think i have everything set up properly with regards to tomcat however I keep getting the error
    "Invalid element 'PCDATA' in context of card expected on event ....."
    The line of code in which this occurs is           
    <jsp:setProperty name="mailer" property="*"/>
    I was wondering if anyone would be able to help me with this and be able to tell me why it thinks this is PCDATA and not jsp code.
    Any help would be much appreciated.

    Check out:
    http://jakarta.apache.org/taglibs/index.html

Maybe you are looking for

  • Garageband w/ Mbox 2 Pro help please. Can we record in stereo? Should we buy a different interface?

    Hello all and thanks in advance for trying to help. I'll try to give all the details straight up so I can get direct answers. I appreciate your help. (By the way this is my first post in the comunity so forgive me if I do something wrong). The long s

  • Can ESB handle SOAP 1.2?

    I have a routing service which is defined based on a schema. If i sent the following message all goes well: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://

  • Safari keeps logging out of logged-in accounts

    Hello, first off let me apologise if this topic has been discussed (and hopefully resolved?) elsewhere, as I'm sure it has. I have searched through the forums and the only similar one I could find was archived and so was unable to reply (thread locat

  • Locking Data in Consolidation Grid

    Hello all - I'm wondering if there is a way to lock/unlock the data on the standard consolidation grid (the one under Process Management). I don't see anything, but everything else can be done there - process management, translations, etc. It seems o

  • Error when importing artifacts using LCM from 11.1.2.2 to 11.1.2.2

    Hello Gurus, I am having issues when perform an LCM import to a different server. Following is what I get Could not read zip file EPMLCM-37015: Cannot Zip. Warning in migrating artifact, "/Configuration/Properties/Application Definition". EPMLCM-3703