Read JSP variables in the % ... % part

Hi there,
got a big problem that i can't solve... maybe you know the answer?
How do i (in <% %> section of JSP code) read a JSP variable?
Please respond (also if you don't understand the question or so).
the code:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<sql:query var="DBklanten">
SELECT * FROM klanten WHERE id = ?
<sql:param value="${param.KBzoektext}"/>
</sql:query>
<c:forEach items="${DBklanten.rows}" var="DBklantenRow">
<%
Properties props = new Properties();
props.put("mail.smtp.host", "hsbmail.hsbrabant.nl");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Uw aanvraag via onze website");
String demail = " Geachte [heer/mevrouw], AND WANT TO READ THE JSP VARIABLE DBklantenRow HERE HOW ???? \n\n" +
message.setText(demail);
Transport.send(message);
%>
</c:forEach>

I don't know why this question is in JavaMail, since it's obviously a question about JSP. But something like this:
<%
Properties props = new Properties();
props.put("mail.smtp.host", "hsbmail.hsbrabant.nl");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Uw aanvraag via onze website");
String demail = " Geachte [heer/mevrouw], %><%=DBklantenRow %><%\n\n" +
message.setText(demail);
Transport.send(message);
%>
I'm sure this is basic JSP, so if this isn't a good answer then ask the JSP experts.

Similar Messages

  • How do I program Instrument I/O Assistant to read a variable in the input string?

    How do I program the Instrument I/O Assistant to read a variable in the input string? I can manually type in the string using the Instrument I/O Assistant using the "Write" or "Query" tools but I do not know how to send a variable input to the Instrument I/O Assistant so that variable can be used inside the "Write" string. For example, I have a power supply whose current I want to set to X Amps. I can type the command "PC10" to program the current to 10 Amps, however I want to be able to program it at any arbitrary current. How do I feed the value X into the code for this purpose?

    You can't. The assistant was designed to be a quick and dirty way to do some basic communication with an instrument. You can turn it into a VI (right click and select Open Front Panel) and modify it so that your write string is an input to the VI or use it as a template and create your own code with VISA Read and Write primatives.

  • Do JSP Variables in the JSP Editor support Generics?

    Do JSP Variables in the JSP Editor support Generics?
    For example List<Client> clients and then introspect all Variables in the Generic Type <Client>?

    Not yet. But you can always "manually" select the list element type in the smart editors. For example the c:forEach, logic:iterate, h:dataGrid smart editors allow you to specify the iteration variable type. Same thing when you insert a list variable in the page.
    M7 Support

  • How to get javascript variable in jsp variable

    Hi all,
    i have a variable str in my javascript function
    var str = somevaluei want this str value in jsp variable in the same page...
    how can this be done..???
    any ideas...
    Thanks

    I dont know if its possible or not.
    Actually it depends on what do you want to do with the variable.
    as far as assisginng value to the hidden variable is concerned it can be done this way.
    <% jsp code
    String hiddenVar = "";
    %>
    < html code
    <input type type = "hidden" name="hidden" vale="<%=hiddenVar %>"
    html ends>
    while in js function you can assign vale to the hidden variable which will ultimately assign value to the JSP variable as follows.
    var str = "value";
    document.form_name.hidden_field_name.value = str.
    hope this hepls.

  • Does a network published shared variable drop the waveform attributes?

    I have the analog input source for a waveform on one NI chassis. The trigger to begin the trend is on another NI chassis. Both of them feed data to a remote Windoze host. I would like to know how I can pass the waveform attributes, ie. Plot Names from the source machine to the Windoze host using a network published shared variable. I am using LV8.0. My two remote chassis are both running RTOS.
    I can see that when I set up the DAQ assistant and named my aquired signals, that these names are passed to a waveform chart on the same block diagram. I can use them to update the Plot Names on my front panel. However, when I create an "Array of Double Waveform based" network published shared variable, and then read that variable from the Windoze host there are no attributes attached. The waveform shows up just fine.
    I would like to be able to have the attributes update the plot name when I change the plot. I will have about 20 plots and I only want to display them a few at a time. I also want the user to be able to select which one they want to look at.

    Hello,
    I think you posted the same question to another thread, received an answer, and have now moved on.  Anyway, the workaround to the problem is to peform flatten to string and unflatten from string operations on the waveform before and after sending it to the shared variable respectively.  See the attached screenshot for the specifics.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Workaround Screenshots.JPG ‏206 KB

  • Accessing JSP variables in Included Javascript

    Hey All,
    I want to hide my javascript to be viewed on the client browser.
    I know we can do that with the javascript include ,But i am using JSP variables in
    Included javascript.I can't access those variables any more.
    Does anybody know any workarround.
    Thanx
    Vijay

    Hi Vijay,
    I am also facing the same problem of hiding javascript in the client browser. My javascript variables are getting initialised on the fly using JSP. Since JSP is compiled on the server side, one can't compile .js file on the client side.
    What u can do is to divide your page into frames with
    <frameset rows="100%,0%">. Now put your form hidden fields or the .js file in frame 2 which is not visible to the user and then assign your jsp variables in the frame2 html/jsp page. Now access your variables from frame2 in frame1 using
    var i = parent.frames[1].document.forms[0].elements[0].value
    Assuming that there is 1 form and 1 hidden field in frame2 html/jsp page.
    I hope u get the logic rite....
    I had done it for application but problem is that our users are real MORONS and they keep doing ctrl+F5 which takes them to the Indexpage.
    If you get some other solution then please mail it to my email address
    [email protected]
    Regards
    Vimlesh

  • Do we Need2Synchronize the jsp variables ?

    Hi, I have noticed that any jsp-variable/object(String, int etc) used in the declaration
    part of a jsp. On compilation by Weblogic ARE NOT declared as class-variables,
    instead are created/initialized as part of the _jspSeervice(Request, Response)
    method in the created/compiled servlet. As they are declared within the service
    method/and not used as a class member of the compiled-servlet, do we need to synchronize
    any of them for concurrency issues ? Also, have delibrately written jsps without
    taking care of the synchronization-issues BUT they haven't failed at all. Is it
    cos' of the above reason ? Someone, please explain.

    You are correct on all counts. There is no need to synchronize.
    Mike
    "chaat" <[email protected]> wrote:
    >
    Hi, I have noticed that any jsp-variable/object(String, int etc) used
    in the declaration
    part of a jsp. On compilation by Weblogic ARE NOT declared as class-variables,
    instead are created/initialized as part of the _jspSeervice(Request,
    Response)
    method in the created/compiled servlet. As they are declared within the
    service
    method/and not used as a class member of the compiled-servlet, do we
    need to synchronize
    any of them for concurrency issues ? Also, have delibrately written jsps
    without
    taking care of the synchronization-issues BUT they haven't failed at
    all. Is it
    cos' of the above reason ? Someone, please explain.

  • How can I obtain the value of a database column in a JSP variable ?

    How can I obtain the value of a table column in a JSP variable?
    For example the <jbo:ShowValue datasource="cl" dataitem="Cont" ></jbo:ShowValue>
    I need to have it in a variable like this:
    <% String cnt=<jbo:ShowValue datasource="cl" dataitem="Cont" ></jbo:ShowValue>; %>
    But it is not workig this way.
    Please help me to obtain the value.
    I am using JDev RC2.
    Thanks.

    Try something like
    String cnt = c1.getRowSet().getCurrentRow().getAttribute("Cont").toString();
    -A
    How can I obtain the value of a table column in a JSP variable?
    For example the <jbo:ShowValue datasource="cl" dataitem="Cont" ></jbo:ShowValue>
    I need to have it in a variable like this:
    <% String cnt=<jbo:ShowValue datasource="cl" dataitem="Cont" ></jbo:ShowValue>; %>
    But it is not workig this way.
    Please help me to obtain the value.
    I am using JDev RC2.
    Thanks.

  • Reading a file in the same directory as the JSP files

    Hi,
    Okay so I have my JSP files in the directory $Catalina/webapps/webservices, I also have a text fire in the same directory called users.txt
    All I want to do is open the users.txt from the JSP program and read from it. But JSP can't seem to find the users.txt.
    Code I have tried include,
    File users = new File("users.txt");
    File users = new File("http://localhost:8080/webservcies/users.txt"); Also File users = new File(new URI ("http://localhost:8080/webservcies/users.txt"));
    File users = new File("webservices/users.txt");
    I guess part of the problem is that I don't know what the JSP working directory is. I assumed it was $Cataline/work/standalone/localhost/webservices
    but even if I use,
    File users = new File("../../../../webapps/webservices/users.txt");
    It doesn't work. Does anyone know how I can read the file? Any help in this matter would be appreciated.

    From within a JSP you have a reference to a PageContext called pageContext. This has a method getServletContext(). From the ServletContext you can find the real path the servlet lives in. So...
    File basePath = new File(pageContext.getServletContext().getRealPath("/"));Now basePath contains your path $Catalina/webapps/webservices. Then it's just a matter of working relative to that, e.g.:
    File usersFile = new File(basePath, "users.txt");

  • How can i execute some code in a jsp page on the same page ? plz read.

    I have made a single JSP Page where in i want to delete users, create users, update table data.
    I have all the UI on the first page. Now i want to write my all JDBC coding on just this single page. I don't want to create 3 separate pages. Can it be done ?

    This is my page !!
    I have 3 separate pages insert.jsp, delete.jsp, update.jsp to implement the jdbc coding. I know that i can get it done by calling a single jsp page using URL rewriting. But i want to code for events on this very page only.
    <%@page language="java"%>
    <%@page import="java.sql.*"%>
    <HTML>
         <BODY>
              <form method=post action="insert.jsp">
                   Username:<input type=text name=username><br>
                   Password:<input type=password name=password><br>
                   <input type=submit>               
              </form>
              <hr>
              <form method=post action="delete.jsp">
                   Username:<input type=text name=username><br>
                   <input type=submit>               
              </form>
              <hr>
              <form method=post action="update.jsp">
                   Username:<input type=text name=username><br>
                   Password:<input type=password name=password><br>
                   <input type=submit>               
              </form>          
         </BODY>
    </HTML>

  • I'm trying to connect a subVI with my VI, they both share common variables and the subVI is not reading one of the variables from the main VI...

    I can't figure out why the subVI will not read this one particular variable from the main VI. How can I figure out how to make sure these two VI's are communicating properly?

    Yes, please post example.
    We could probably give you an answer rather quickly if you did.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

  • I get to the part when i have to enter my user name and pass...read this

    i get to the part when i have to enter my user name and pass and i am able to enter my username but when u get to the part of password i cant write anything please someone tell me what to do i cant enter my system (solaris 10 x86)and i just installed it i cant see it please helppppp!!!!

    umm. i hope you are aware of the fact that when you enter your password in Solaris you won't see any evidence of it until you press "enter".. hence, there are no "*" or similar which indicates that you are typing your password...
    7/M.

  • String variable limitation the JSP

    Hai..
    I am declaring all my string variables in one setup.jsp file. I am including that file to different files to get the defined variables.
    Now i am facing problem in this. After certain limit if I add string value then the JVM crashes... If the added new string values were removed then the system working fine.
    Here my doubt is is there any limitation in the jsp to declare the string variables.
    Please thro me some idea on this..
    Thanks in advance
    Kumarappan.s

    Hi,
    I think, There is no limit on declaring string variables
    Regards
    Sekhar

  • How do I pass the part of the url that matched url-pattern to JSP?

    Hello,
    I have a web app called ptest.war deployed in JBoss. In my web.xml I have:
    <servlet-mapping>
    <servlet-name>GetImage</servlet-name>
    <url-pattern>/images/*</url-pattern>
    </servlet-mapping>
    and:
    <servlet>
    <servlet-name>GetImage</servlet-name>
    <jsp-file>DoImageRequest.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
    </servlet>
    In DoImageRequest.jsp, I want to know what was requested by the user (so I can set some response headers and then re-direct to the image they requested), so if I go to:
    http://localhost/ptest/images/i1.jpg
    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request object give me that string.
    request.getServletPath() returns "/images" and request.getPathInfo() returns "/i5.jpg".
    So do I need to construct what the user asked for by concatenating these two values?
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?
    Many Thanks,
    Paul Smith

    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request >object give me that string.Even if you manage to construct that, such a request path would be intercepted by your jsp because it maps to /images/*.
    You would end up with infinite recursion.
    To circumvent that, you can change the folder that stores the image - call it something like img and then you just need append the request.getPathInfo().
    getServletContext.getRequestDispatcher("/img"+req.getPathInfo()).forward(req,res);
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that >without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?You could have a filter intercept all requests for *.img, add the response headers and pass the request along to the actual resource. That would be easier and more intuitive. If your web app has a good fronting like an apache web server, I think you can cache your images on the web server and set a property that would instruct the web server to set a no-cache header in response when it serves the image.
    ram.
    Edited by: Madathil_Prasad on Mar 26, 2010 7:20 PM

Maybe you are looking for