Implementing if-statement in jsp-sites

Hi,
I have a Vector in a jsp-Site as a property that I can refer to in the following way:
<c:set var="mo" value="${requestScope.montag}"/>
Now I want to test if the second element of this vector equals "0" or not.
I tried things like:
<logic:equal scope="request" name="${montag[0]}" value="0">
or
<logic:equal parameter="${requestScope.montag[0]}" value="0">
but they don't work, does anybody of you have an idea?
Kind regards
Thomas

Try c:if
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
Look under JSTL - flow control

Similar Messages

  • Jsp sites access control

    Hi,
    i am new in web-app-programming.
    I have developed a few jsp pages. One of them is login page and the other should only be accessable after logging in the login page.
    The current state is: the pages can also be accessed directly with the url like this: "http://localhost:8080/application_root/my_url_pattern/somepage.jsp".
    I am looking for a solution to avoid the direct access per url.
    my ideas are:
    1) set the render control of the jsp site-> it works well-> but a bit complex
    2) out source the jsp site -> save the jsp sites somewhere else as the applicationroot-> I have the problem that the site could no be found. Can somebody tell me how can i solve this problem.
    thank u
    Ming
    Message was edited by:
    m_z

    You can set up a servlet filter in the web.xml. That lets you intercept every single request to certain areas of the app, and modify/redirect it if necessary.
    Example: This sets up a filter that runs on all requests to the "/tools" directory:
    In web.xml:
       <filter>
         <filter-name>testFilter</filter-name>
         <filter-class>com.TestFilter</filter-class>
       </filter>
       <filter-mapping>
         <filter-name>testFilter</filter-name>
         <url-pattern>/tools/*</url-pattern>
       </filter-mapping>And an example java class of a filter. This one just logs the request URI.
    package com;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    public class TestFilter implements Filter{
         public void init(FilterConfig arg0) throws ServletException {}
         public void destroy() {}
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              if (request instanceof HttpServletRequest){
                   HttpServletRequest req = (HttpServletRequest)request;
                   System.out.println("Servicing request for " + req.getRequestURI());
                   chain.doFilter(request, response);
    }

  • Internal error if pointing on jsp-site

    I set up the Sun ONE Webserver 6.1 SP2 and deployed a webapp named prodass3. It functioned, but displaying jsp-sites.
    If I point to a HTML-site within the webapp, the HTML-site is displayed correctly. Access-log entry:
    192.168.200.53 - - [08/Jun/2004:17:34:55 +0200] "GET /prodass3/index.html HTTP/1.1" 200 1734
    But if I point to a JSP-site, I get an internal error. Access-log entry:
    192.168.200.53 - - [08/Jun/2004:17:46:42 +0200] "GET /prodass3/index.jsp HTTP/1.1" 500 305
    I think the JSP-files would not be compiled. But there is no error or something like that..
    Java Globally and Java for class vsclass1 are enabled.
    Java Home Path: C:/Programme/Sun/WebServer6.1/bin/https/jdk/
    What am I doing wrong?
    Kind regards, Jonas

    I can't find in server.xml a 'wrong' classpath like you mentoined above.
    I also copied the jdk (1.4.2) from the developing environment on the server maschine and linked the java home to the new path.
    I also restarted the virtual server..
    Here the server.xml:
    Can, you tell me is there something else wrong?
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved.
    Use is subject to license terms.
    -->
    <!DOCTYPE SERVER PUBLIC "-//Sun Microsystems Inc.//DTD Sun ONE Web Server 6.1//EN" "file:///C:/Programme/Sun/WebServer6.1/bin/https/dtds/sun-web-server_6_1.dtd">
    <SERVER qosactive="false">
    <PROPERTY name="docroot" value="C:/Programme/Sun/WebServer6.1/docs"/>
    <PROPERTY name="accesslog" value="C:/Programme/Sun/WebServer6.1/https-gsa_tomcat-test.gartenmann.ch/logs/access"/>
    <PROPERTY name="user" value=""/>
    <PROPERTY name="group" value=""/>
    <PROPERTY name="chroot" value=""/>
    <PROPERTY name="dir" value=""/>
    <PROPERTY name="nice" value=""/>
    <LS id="ls1" port="80" servername="gsa_tomcat-test.gartenmann.ch" defaultvs="https-gsa_tomcat-test.gartenmann.ch" security="false" ip="any" blocking="false" acceptorthreads="1"/>
    <MIME id="mime1" file="mime.types"/>
    <ACLFILE id="acl1" file="C:/Programme/Sun/WebServer6.1/httpacl/generated.https-gsa_tomcat-test.gartenmann.ch.acl"/>
    <VSCLASS id="vsclass1" objectfile="obj.conf" rootobject="default" acceptlanguage="off">
    <PROPERTY name="docroot" value="C:/Programme/Sun/WebServer6.1/docs"/>
    <VS id="https-gsa_tomcat-test.gartenmann.ch" connections="ls1" mime="mime1" aclids="acl1" urlhosts="gsa_tomcat-test.gartenmann.ch" state="on">
    <PROPERTY name="docroot" value="C:/Programme/Sun/WebServer6.1/docs"/>
    <USERDB id="default"/>
    <SEARCH>
    <WEBAPP uri="/search" path="C:/Programme/Sun/WebServer6.1/bin/https/webapps/search" enabled="true"/>
    </SEARCH>
    <WEBAPP uri="/prodass3" path="C:/Programme/Sun/WebServer6.1/https-gsa_tomcat-test.gartenmann.ch/webapps/prodass3" enabled="true"/>
    </VS>
    </VSCLASS>
    <JAVA javahome="C:/Programme/Java/jdk1.4.2jdev/" serverclasspath="C:/Programme/Sun/WebServer6.1/bin/https/jar/webserv-rt.jar;${java.home}/lib/tools.jar;C:/Programme/Sun/WebServer6.1/bin/https/jar/webserv-ext.jar;C:/Programme/Sun/WebServer6.1/bin/https/jar/webserv-jstl.jar;C:/Programme/Sun/WebServer6.1/bin/https/jar/ktsearch.jar" classpathsuffix="" envclasspathignored="true" nativelibrarypathprefix="" debug="on" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="-1">
    <JVMOPTIONS>-Djava.security.auth.login.config=C:/Programme/Sun/WebServer6.1/https-gsa_tomcat-test.gartenmann.ch/config/login.conf</JVMOPTIONS>
    <JVMOPTIONS>-Djava.util.logging.manager=com.iplanet.ias.server.logging.ServerLogManager</JVMOPTIONS>
    <JVMOPTIONS>-Xmx256m</JVMOPTIONS>
    <SECURITY defaultrealm="native" anonymousrole="ANYONE" audit="false">
    <AUTHREALM name="file" classname="com.iplanet.ias.security.auth.realm.file.FileRealm">
    <PROPERTY name="file" value="C:/Programme/Sun/WebServer6.1/https-gsa_tomcat-test.gartenmann.ch/config/keyfile"/>
    <PROPERTY name="jaas-context" value="fileRealm"/>
    </AUTHREALM>
    <AUTHREALM name="native" classname="com.iplanet.ias.security.auth.realm.webcore.NativeRealm">
    <PROPERTY name="jaas-context" value="nativeRealm"/>
    </AUTHREALM>
    <AUTHREALM name="ldap" classname="com.iplanet.ias.security.auth.realm.ldap.LDAPRealm">
    <PROPERTY name="directory" value="ldap://localhost:389"/>
    <PROPERTY name="base-dn" value="o=isp"/>
    <PROPERTY name="jaas-context" value="ldapRealm"/>
    </AUTHREALM>
    </SECURITY>
    <RESOURCES/>
    </JAVA>
    <LOG file="C:/Programme/Sun/WebServer6.1/https-gsa_tomcat-test.gartenmann.ch/logs/errors" loglevel="info" logtoconsole="true" usesyslog="false" createconsole="false" logstderr="true" logstdout="true" logvsid="false"/>
    </SERVER>

  • After closing an Applet, how can I say a HTML/JSP Site to load a new site?

    Hi!
    I have a problem. I�m writting a little chat, and after qutting I want to say my HTML/JSP site to load or go further to another page.
    This is possible because a saw this already, but i didn�t got the way how!
    Thnx
    Ren�

    Hi,
    I assume you mean with "after quitting" pressing the Quit button.
    Your JSP can use the forward-statement to move to another JSP or HTML. You can find it on Suns
    JSP-Syntax Card.
    I hope I could help you
    Frank Rettweiler

  • Using return statement in jsp

    Hi all,
    I am using return statement in JSP page after a redirect to stop executing that page. If the data bean is not present then it must go to previous page. When this return statement is executed the previous page is displayed but url in browser remains same. Why it is so ?. Is there any other way to tell a JSP page to stop executing and redirect to another page.
    rgds
    Antony Paul

    Hi Antony,
    do you use the "forward()" method or the "redirect()" method???
    rgds
    Howy

  • Logs or stats in iWeb site?

    Anyone know if there's a way to do easy referrer logs and stats for iWeb sites? I've found StatCounter, but that requires embedding an HTML code into every page, which is tough since you have to go in and re-edit it every time you modify something in iWeb.
    It'd be nice to see who's linking my site and pages and entries since I have such a layrinthine site these days - any suggestions that don't involve the 2-step process of pasting HTML code into each page evry time I edit it?

    there is no other way - but there are fast ways! check this video tutorial:
    http://karreth.com/iweb/How%20To%20Add%20A%20StatCounter.html
    max

  • INSERT statement with JSP

              Does anyone know how to create an INSERT statement with JSP using
              variables??
              I can do the insert if I code the values of the variables in the statement,
              but when I try to use variables to do the insert it tries to insert the
              variable name and not the value of the variable into the table.
              Thanks,
              Doug
              

    "Doug Schaible" <[email protected]> wrote in message news:<bicO7.1279268$[email protected]>...
              > I can do the insert if I code the values of the variables in the statement,
              > but when I try to use variables to do the insert it tries to insert the
              > variable name and not the value of the variable into the table.
              Doug,
              I think you missed the <%= blahblah %> syntax.
              Regards
              drit
              

  • How to implement content caching for jsp page ?

    Hello everyone,
    I am reading an article <Servlets and Jsp Best Practice>,at
    http://developer.java.sun.com/developer/technicalArticles/javaserverpages/servlets_jsp/#author, on one section it is saying :
    "Cache content: You should never dynamically regenerate content that doesn't
    change between requests. You can cache content on the client-side, proxy-
    side,or server-side. "
    Now I am working on a project. For every user, some of the content servlet generated will be the same for at least a week . I am thinking if I implement caching for these jsp pages, that would increase performace a lot.
    But I have no idea how to implement it either client-side or server-side, can someone give me a hint ?
    Thanks,
    Rachel

    You mean actually you are caching the response stream
    and the key to distinguish between different response
    streams are made of user's different request
    parameters. And the filter's function is to intercept
    the request to see if this request parameter's
    combination already exists in the Hashmap,then either
    use the cached response or forward to
    servlet.....really interesting...Do I get it right ?Yes that's it in a nutshell.
    >
    Then how do you build those response streams in
    advance ? You did it manually or have some mechanism
    to build it automatically ?
    The data gets cached the first time somebody visits the page.
    Find some examples on Filters, and take a look at the HttpServletResponseWrapper class. You need to cache response headers as well as the body. Another pitfall that you might run into is handling an If-modified-since header on the request. Don't cache the results of those requests.
    -Jonathan
    >
    Thanks again !
    Rachel

  • Inserting your own sql-statements in JSP

    How do I use my own sql-statements in JSP combined with the ones
    generated by JDeveloper?
    It seems to me that the following sentences are the ones
    generating the sql for inserting in a database:
    <jbo:DataSource id="ds" appid="MimPKG.MimPKGModule"
    viewobject="BidragView"/>
    <jbo:Row id="newRow" datasource="ds" action="Create">
    <jbo:SetAttribute dataitem="*"/>
    </jbo:Row>
    I would like to have more control and therefore I need to make
    my own sql-statements.
    Is that possible?
    Thanks
    Leise

    You can use ExecuteSQL data tag to do so. It allows you to
    include your own query like insert, update etc.

  • Cost of a jsp site

    I'm new to Java Server Pages and want know what the cost of setting up a JSP site would be (ie: what software do i need; is it free or does it cost and if it is free is it worth getting). I am not interested in the cost of hardware.
    Thanks,
    Chris McCorriser

    The downside to both of these is
    that there is no technical support. Not strictly true. There is plenty of info in forums and lists like this, for both apache http server and tomcat. It depends what you mean by support. If you want to be a 'Gold customer' and have someone at the end of the phone 24-7 who can sort out any of your problems (**yawn**), then fine... I'm sure it will be great experience for you!You won't get that with Apache Foundation, but not all (hardly any?)new ventures have the money for that sort of setup anyway...
    There are loads of survey estimates that put figures of up to 75% of all webservers being apache. Must say something surely?
    What I would say tho, is that large amounts of support info for apache assume you are on a UNIX-variant platform... which admittedly is a far better solution, but not so helpful if you are a Gates disciple.

  • Using sjsws to host many small servlet/jsp sites on one server

    Hello. I visited the web page at http://www.sun.com/software/products/web_srvr/features.xml, which mentions that sjsws supports mass hosting of thousands of domains. Anyone knows more information about this feature? I want to find out whether sjsws is a good choice for hosting many small servlet/jsp sites on one server.
    Some time ago, I tried using apache+tomcat to host many small servlet/jsp sites on one server. But the result was not satisfactory. If a private tomcat/jvm is used for each site, too many resources are consumed and as a result, not many sites can be hosted on one server. If a shared tomcat/jvm is used for all sites, the resources consumed are reduced, but it becomes very difficult to isolate the sites. Is it possible to overcome such problems with sjsws?
    Thx.

    Of course you dont have to use multiple VMs to host multiple applications.
    You can either choose to have multiple Virtual Servers, all in one instance of the web server, serving multiple applications. In this case only one java VM is used.
    Or you can go in the route posted in the link above, in which there is only one "physical" virtual server, with many dynamic virtual servers.
    Whether you chose to have many multiple web applications, or do the server division in a similar way to what is described in the blog, it is up to you.
    Many different web applications will give you more fine level control on the application separation, but it will probably also mean greater resource consumption associated to the web application managing.
    Less web applications, but with dynamic separation, in a similar way to what is described in the blog, will give a lesser control on the applications, but will save you a good number of resources.
    SJS Web Server is known to work in massive web sites, with very high number of JSPs and Servlets. There is some real life examples of this massive hosting. Maybe others can provide some numbers here :P

  • Import statement in JSP

              Hi
              I am maintaining a system done by one of our vendors.
              Application is deployed in WLS 7.0.
              When I imported the Jsp's into my IDE , I got errors where java.util classes are
              used in the JSP's and the import statement is missing.
              Most of the Jsp's are like this,
              It is working fine in the production server.
              In the IDE i am forced to put the import statement and that is what I expect.
              But how can it work in the production server without any issue.
              Can someone advise me on this
              Thanks
              DN
              

    <%@page import="java.util.calendar" %>
    Oops... forgot the "page" in there ...That's what I get for using GUI's too much!!! :)

  • Error msg in IF ELSE statement in jsp page, Need help

    Below is my code I am trying to execute, but keep getting an error:
    Compilation error occured:
    Found 1 errors in JSP file:
    D:\\http\\proFolder\\student.jsp:130: Syntax: "}" inserted to complete StatementNoShortIf
    <%if (assess.getNumberValue() > 0) {%>
         <%if ((assess.getTotalCost(appForm)) <= (assess.getNumberValue())) {%>
         <strong><%=assess.getTotalCost(appForm)%></strong>      
            <%}%>
    <%}%>
    <%else {%>
         <%=assess.getTotalCost(appForm)%>
    <%}%>Basically, What I am trying to do is follow this logic:
    IF method getNumberValue() is greater then 0, then execute the second IF statement that
    is, If method getTotalCost() is less then or equal to getNumberValue() then display value of method getTotalCost()
    End Second IF
    End First IF
    Now if the First IF fails ( that is getNumberValue() is not gether then 0)
    then execute the else statement
    Could someone please guide me what I am doing wrong, and what would be the correct way of write the IF else code
    Thanks,

    <%     if (assess.getNumberValue() > 0) {
              if ((assess.getTotalCost(appForm)) <= (assess.getNumberValue())) {
    %>
                   <strong><%=assess.getTotalCost(appForm)%></strong>      
    <%          
    %>
    <%
         else {
    %>
              <%=assess.getTotalCost(appForm)%>
    <%
    %>

  • Flex 3 :Help needed in implementing View States

    Hi 
    I am new to Flex , i am trying to understand View States , tried for one hour but got confused .
    (Basically by seeing the examples i understood the concept , but failed to implement ) 
    Please help .
    Assume my requirement is at the load of the page , i want to show an Login Button and a Chnage State Button (common button) only .and when the Change State button is clicked on ,i want to show the Register Button .
    So for this i made two Forms , and a common button .
           <mx:Form id="RegForm">
                <mx:Button label="RegFormButton" id="RegFormButton"/>
            </mx:Form>
            <mx:Form id="loginForm">
                        <mx:Button label="LoginButton" id="loginButton"/>
            </mx:Form>
    <!-- A common button for both the States-->
      <mx:Button label="Change State"
                  click=""/>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" currentState="Register">
    <mx:states>
    <mx:State name="Register">         
    <mx:SetProperty   target="RegForm"   value="Register"/>
    </mx:State>
    <mx:State name="loginForm">
    <mx:SetProperty   target="loginForm"   value="Login"/>
    </mx:State>
    </mx:states>
    ( I think some how i can write the Logic to chnage to the current state to loginForm when user clicks with some inline code , but please tell me At the start of the page please tell me why I am not able to show the Register.

    sorry for posting a dumb question .
    I realized my mistake .

  • Odd results from SQL statement in JSP

    Hi.
    Getting very strange results from my SQL statement housed in my JSP.
    the last part of it is like so:
    "SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME, ..." +
    "REQUESTOR_EMAIL" +
    " FROM CHANGE_CONTROL_ADMIN a INNER JOIN CHANGE_CONTROL_USER b " +
    "ON a.CHANGE_CTRL_ID = b.CHANGE_CTRL_ID " +
      " WHERE UPPER(REQUESTOR_NAME) LIKE ? ";   I've set the following variables and statements:
    String reqName = request.getParameter("requestor_name");
    PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
    prepstmt.setString(1, "%" + reqName.trim().toUpperCase() + "%");
    ResultSet rslts = prepstmt.executeQuery();
    rslts.next();
    int aidn = rslts.getInt(1);          
    int actbox = rslts.getInt(2);     String reqname = rslts.getString(3).toUpperCase();
    String reqemails = rslts.getString(4);
    String bizct = rslts.getString(5);
    String dept = rslts.getString(6);
    String loc = rslts.getString(7);
    Date datereq = rslts.getDate(8);
    String busvp = rslts.getString(9);
    AND SO ONSo then I loop it, or try to with the following:
    <%
      try {
      while ((rslts).next()) { %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    rslts.close();
    selstmt.close();
    catch(Exception ex){
         ex.printStackTrace();
         log("Exception", ex);
    %>AND so on, setting 13 getXXX methods of the 16 cols in the SQL statement.
    Trouble is I'm getting wildly inconsistent results.
    For example, typing 'H' (w/o quotes) will spit out 20 duplicate records of a guy named Herman, with the rest of his corresponding info correct, just repeated for some reason.
    Typing in 'He' will bring back the record twice (2 rows of the complete result set being queried).
    However, typing in 'Her' returns nothing. I could type in 'ell' (last 3 letters of his name, Winchell) and it will again return two duplicate records, but typing in 'hell' would return nothing.
    Am I omitting something crucial from the while statement that's needed to accurately print out the results set without duplicating it and that will ensure returning it?
    There's also records in the DB that I know are there but aren't being returned. Different names (i.e. Jennifer, Jesse, Jeremy) won't be returned by typing in partial name strings like Je.
    Any insight would be largely appreciated.
    One sidenote: I can go to SQL Plus and accurately return a results set through the above query. Having said that, is it possible the JDBC driver has some kind of issue?
    Message was edited by:
    bpropes20
    Message was edited by:
    bpropes20

    Am I omitting something crucial from the while
    statement that's needed to accurately print out the
    results set without duplicating it and that will
    ensure returning it?Yes.
    In this code, nothing ever changes the value of reqname or any of the other variables.
      while ((rslts).next()) { %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    } You code needs to be like this:while (rslts.next()) {
      reqname = rslts.getString(3).toUpperCase();
      reqemails = rslts.getString(4);
      bizct = rslts.getString(5);
      dept = rslts.getString(6);
      loc = rslts.getString(7);
      datereq = rslts.getDate(8);
      busvp = rslts.getString(9);
    %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    There's also records in the DB that I know are there
    but aren't being returned. Different names (i.e.
    Jennifer, Jesse, Jeremy) won't be returned by typing
    in partial name strings like Je.Well, you're half-right, your loop won't display all the rows in the result set, because you call rslts.next(); once immediately after executing the query. That advance the result set to the first row; when the loop is entered, it starts displaying at the 2nd row (or later if there are more next() calls in the code you omitted).

Maybe you are looking for

  • FORMAT C DRIVE

     I have hp Pavilion 15-n209TX, I already created recovery disk (5 disk), and also there is 1 drive name as recovery disk, i just want to know how to format my C DRIV E ONLY using R-disk or R-drive? and i also want to know how to split DRIVERS ONLY fr

  • Can't open photo in Elements 9

    I am unable to open the edit page after not saving the last photo I worked on in elements 9 can anyone please advise

  • Linux net command showing incorrect output if executing from java.

    I am trying to execute a net rpc registry on red hat linux box from java using Runtime. I have stored the command in a String variable. When the execute the command from java it throws an error saying that "Invalid registry path" however the same com

  • Inventory number and value to be made zero on an existing stock item!

    Hi Guys, How can a Inventory ( Stock item that is already in warehouse) be written off or made zero in item number and value? Regards, Harsha

  • Histogram mean and median in Photoshop are different than in MATLAB

    Hi guys. I'm currently using Photoshop CS3 on my PC and I've been tasked to do some image analysis research. I used Photoshop to analyze a pool of 100 files to find the mean and median of their (intensity/gray) histograms. (Using the im2gray function