Using JSP declaration tags and expression tags

I am trying to use JSP without embedding any business logic into my view pages.
I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?
And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.
Thanks

PaulOckleford wrote:
I am trying to use JSP without embedding any business logic into my view pages.
I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?You can use the JSTL <c:set> for that. But I would still prefer the Servlet above that.
And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.You can find here at least one: [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html].

Similar Messages

  • JSP declaration Tag

    Dear All,
    Is it ok to use JSP declaration tag? I have heard if we use the declaration tag then this variable name will be shared by all threads and the particular variable will be overridden. Is it true? please advise me on this? can we use this tag in our Jsp files.
    Thanking you in advance.
    Regards,
    Venkat

    Yes, it is true that the scope of variable in decalaration tag becomes global. It is as good as declaring a public variable in core java context.
    In my opinion one should avoid using the declaration tag.
    As there should be less and less public variable in core java class. Every variable should be private to the class and accessing the variable should be only through the instance of the class.

  • How to use JSP custom tag lib in PAR file?

    Hi All,
    I am trying to customize mastheaderpar file. For that I have downloaded relevant par file and making the changes accordingly.
    As part of the changes I would require to use JSP custom tag library in my par file.
    I have the TLD file and relevant classes in the jar file. I would like to know where and what kind of modifications have to be done to use the jsp custom tag library.
    I tried modifying some things in portalapp.xml but was not successful.
    Please help me on how to proceed with this? It would be great if you can provide the xml entry to use this tag library
    Thanks
    Santhosh

    Hi Johny,
    Thanks for the reply. Actually I am able to change colors etc. with out any problem.
    My requirement is to use XMLTaglib in mastheader par file. This tag lib is from apache tomcat. I have the relevant TLD and class files. I copied TLD file into taglib dir of portal-inf and class file in src api.
    And I have added the following line in portalapp.xml under component-profile section of default
    <property name="tlxtag" value="/SERVICE/Newmastheader/taglib/taglibs-xtags.tld">
    Is this the right way to use tag lib? Actually before adding this line I used to get the error saying "Error parsing taglib", but now the error does not occur and I am getting new error. This is an exception in one of the taglib classes.
    Could any one provide me some inputs on how to check this error?
    Thanks
    Santhosh

  • Unable to use jsp:useBean tag

    when I use
    <jsp:useBean id="addressBean" class="AddressBean" scope="session"/>
    I get the following error
    Exception Details: org.apache.jasper.JasperException
    Unable to compile class for JSP No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path.
    So my question is how to use the <jsp:useBean> tag in JSC

    Please see my message How to set developer's mode for oracle jsp engine.
    As a very early warning of the future, this way of setting configuration paramemter in web.xml for oracle jsp engine will be deprecated in the next major version of oc4j and desupported probably later on. Yes, it is still supported in 10.1.3 and the next major version, though.

  • Displaying Applet in JSP Using jsp:plugin tag

    The following code is not working eventhough i downloaded to JRE plug-in .Please help me to work the
    following code in JSP.
    <jsp:plugin code="mani.Clock2.class"
    codebase="/classes/" width=300 height=300
    jreversion="1.3"
    nspluginurl="http://java.sun.com/products/plugin/1.1.3/plugin-install.html"
    iepluginurl="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <jsp:fallback>
    <font color=#FF0000 size=10>Sorry Error While Loading Applet </font>
    </jsp:fallback>
    </jsp:plugin>

    why don't ypu just use the <applet> tag?

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • How to open a doc file using jsp Anchor tag

    when i am trying to open a doc file using a jsp it is opening with out proper alignment.
              how to open a doc file with proper alignment using Anchor Tag in JSp Page
              

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

  • Unable to run jsp as include using jsp:include tag

    I am trying to run the basic jsp:include sample provided by Oracle in OC4J 10g. When I run the code, It seems like include file is treated as text/html and not run at all. Can somebody help me in figuring out what I am missing here..
    Here is the code for main.jsp
    <jsp:include page="content.jsp">
    <jsp:param name="a" value="1"/>
    <jsp:param name="b" value="2"/>
    <jsp:param name="c" value="3"/>
    </jsp:include>
    Here is the code for content.jsp
    <p> Included Content </p>
    <p> Parameters - ${param.a}, ${param.b}, ${param.c} </p>
    When I run this code in JDeveloper10g using the embedded OC4J as well as Application Server 10g, I get the following output.
    Included Content
    Parameters - ${param.a}, ${param.b}, ${param.c}
    Note that the parameter values are not substituted properly.
    Thanks in advance
    Niraj

    javax.servlet.ServletException: com/sun/tools/javac/Main (Unsupported major.minor version 49.0)
    This is your problem either your tomcat or eclipse is pointing to a wrong jre
    here the problem is you are trying to run a code that was compiled using j2sdk1.5 in j2sdk1.4

  • Populating combobox in jsp page from javabean using jsp:getProperty tag

    hi,
    i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean.
    please reply me.
    <jsp:useBean id="bidpageid" class="RFPSOFTWARE.Bid" scope="session" />
    <jsp:setProperty name="bidpageid" property="*"/>
      <table  width="50%" align="center" border="0">
       <tr>
        <td  width="30%" align="left"><h4><b><label>Date (dd/mm/yyyy) </label></b></h4> </td>
        <td><input type="text" name="date" size="11" maxlength="10" readonly="readonly" value="<jsp:getProperty name="bidpageid" property="date"/>"  > </td>
      </tr>
      <tr> <td > </td> </tr>
      <tr>
        <td  width="30%" align="left"><h4><b><label>ProductId </label></b></h4> </td>
        <td><select name="productid" tabindex="1" size="1" >
          <option  value="<jsp:getProperty name=bidpageid" />Sachin</option>
          <option value="Hello">Vishal</option>
        </select></td>
      </tr>  and the javabean for Bid is as follow :
    import java.util.Date;
    import RFPSOFTWARE.Product;
    public class Bid{
    private Product product;
    private Integer bid_id;
    private String description;
    private Date date= new Date();
    public Integer getBid_id() {
    return bid_id;
    public Date getDate() {
    return date;
    public String getDescription() {
    return description;
    public Product getProduct() {
    return product;
    public void setBid_id(Integer bid_id) {
    this.bid_id = bid_id;
    public void setDate(Date date) {
    this.date = date;
    public void setDescription(String description) {
    this.description = description;
    public void setProduct(Product product) {
    this.product = product;
    }

    No Sir,
    I think I did not explained clearly.what I try to say is I dont want to use JSTL.I am using only Scriptlets only.I can able to receive the values from the database to the resultset.But I could not populate it in Combobox.
    My code is :
    <tr>
    <td width="22%"><font color="#000000"><strong>Assign To Engineer</strong></font></td>          
    <td width="78%">
         <select NAME="Name" size="1">
    <option><%=Username%></option>
    </select> </td>
    </tr>
    in HTML
    and in Scriptlets:
    ps1 = con.prepareStatement
              ("SELECT Username FROM Users");
              rs2=ps1.executeQuery();
              System.out.println("SECOND Succesfully Executed");
              while(rs2.next())
                   System.out.println("Coming inside rs2.next loop to process");
                   Username=rs2.getString("Username");
                   System.out.println("Success");
                   System.out.println("The value retrieved from UsersTable Username is:"+Username);
    In the server(Jboss console) I can able to display the username but I could not populate it in the Combobox .
    Can you now suggest some changes in my code,Please..
    Thanks a lot
    With kind Regds
    Satheesh

  • Problem with flush=true in the jsp:include tag

    Hello
    I have deployed a JSP based application , based on the apache struts framework. The web server is Sun One Webserver 6 Service Pack4, on a windows 2000 machine
    The same application was tried on SunONE application server 7, and it works without any problem. However in this case the following error , on the page
    javax:servlet.jspexception:Illegal to flush within a custom tag
    Does this mean flush="true" is not allowed within custom tags
    Or is there a workaround for this
    Any help is appreciated
    thanks
    - Aniruddha

    Hi,
    This is a known problem, ��flush before you include�� limitation in JSP 1.1.
    As a result, you have to state flush="true" every time you include a jsp using <jsp:include> tag if you are using JSP1.1.
    Fortunately, it is fixed in JSP1.2. The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a ��true�� value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is ��false��.
    Gary Wang
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Flush in the jsp:include tag

    should I state flush="true" every time I include a jsp using <jsp:include> tag in a jsp pages? For example I am trying to include a menu bar on the top of every jsp pages. Should I flush the buffer every time? if not, will it affect the performance?
    Thank you
    Cal

    Hi,
    This is a known problem, ��flush before you include�� limitation in JSP 1.1.
    As a result, you have to state flush="true" every time you include a jsp using <jsp:include> tag if you are using JSP1.1.
    Fortunately, it is fixed in JSP1.2. The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a ��true�� value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is ��false��.
    Gary Wang
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • JSP declarattion tag

    hi all
    I am confused on this one; please help.
    In a JSP declaration tag , the variables that we declare become class's private vars upon compilation. Similarly, when we declare methods in a declaration tag they become private methods of the compiled class. Now, I wud like to know whether those vars can be accessed inthe methods???

    They can be accessed in the methods, but you should restrain yourself from doing so.
    <%!
      int i = 100; 
      String name = "Bob";
      public int nextInt(){
        return i++;
      public void setName(String name){
        this.name = name;
    %>The issue here is that variables declared in this manner are shared by all users of that jsp page - ie its an instance attribute of the class. Because only one instance of a servlet/jsp is created to service all requests, this attribute is shared.
    The best approach is to declare variables only within your methods, and between <% %> tags.
    If you need to access the variables in your methods (such as setName) pass the parameters up to them.
    Cheers,
    evnafets

  • How to call a method repeatedly with JSP custom tag?

    This senerio is very similar to the usage of StringBuffer.
    I have a problem which can be solved easily with scriptlets:
    <% NameValuePair nvp = new NameValuePair(request.getQueryString()); %>
    <a href="foo.html?<%=nvp.add(name1", "value1").add("name2", "value2").toString();%">">Foo</a>
    <a href="bar.html?<%=new NameValuePair(request.getQueryString()).add("x", 1).add("y", 2).toString()%>">Bar</a>
    But I cannot use scriplets because it's turned off. I can only use jsp custom tag / jstl. How would I implement this functionality with a custom tag? How would the JSP code look like? Our container supports JSP 2.0.
    Thanks.</a>

    hi,
    you can do within 2 step-
    1) use <%@page import="your_java_class"%>
    2)use scriptlet code <%...%> and write coding in this tag.
    means create instance of your java class .
    <% your_java_class obj1=new your_java_class();
         obj1.method_of_your_java_class();
    %>or
    3) you can make javabean to use method of java class.[Best option]
    Thanx
    Ranvijay

  • JSP include tag not showing page content

    Below is my code for a JSP page that uses JSP:include tag to include footer.jsp. The footer page does not display on show_email_entry.jsp. The error I am getting is variable emailAddress cannot be resolved. What am I doing wrong?
    Here is my code.
    show_email_entry.jsp
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <%@ include file="../includes/header.htm" %>
    <body>
    <%
    String firstName = request.getParameter("firstName");
    String lastName = request.getParameter("lastName");
    String emailAddress = request.getParameter("emailAddress");
    %>
    <h1>Thanks for joining our email list</h1>
    <p>Here is the information that you entered:</p>
    <table cellspacing="5" cellpadding="5" border="1">
    <tr>
    <td align="right">First name:</td>
    <td><%= firstName %></td>
    </tr>
    <tr>
    <td align="right">Last name:</td>
    <td><%= lastName %></td>
    </tr>
    <tr>
    <td align="right">Email address:</td>
    <td><%= emailAddress %></td>
    </tr>
    </table>
    <jsp:include page="footer.jsp" flush="true" />
    <p>To enter another email address, click on the Back <br>
    button in your browser or the Return button shown <br>
    below.</p>
    <form action="../email6/join_email_list.html" method="post">
    <input type="submit" value="Return">
    </form>
    </body>
    </html>
    FOOTER.JSP page:
    <%@ page import="java.util.Date" %>
    <p><i><%= emailAddress %> was added on <%= new Date() %>.</p>

    The [url http://java.sun.com/products/jsp/syntax/2.0/syntaxref209.html#1003408]@include directive and the [url http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828]<jsp:include> have two different functionalities.
    From the [url http://java.sun.com/products/jsp/syntax/2.0/syntaxref20.html] reference page:
    Include Directive : Includes a resource of text or code when the JSP page is translated.
    <jsp:include>
    Includes a static resource or the result from another web component
    (italic emphasis is mine)
    Basically the @include directive is like "copy and paste this file into the JSP and then compile"
    jsp:include is "run this web page, and add the result of that to my current response"
    So jsp:include can only include complete standalone JSPs.
    Do you see now why it would throw an error message with your example?
    Cheers,
    evnafets

  • JSP 2.0 and EL

    I want to use JSP 2.0 and EL with tomcat 5
    When i use EL into a JSP Page, it seems like tomcat does not care about it and so does not interpret the EL expressions ( in the opposite, it displays the expressions )
    Is there sometihng to do to force tomcat to interpret such expressions ?
    Another thing. Is there something to add in the web.xml file to use JSTL 1.1 under tomcat 5? i seem to see that only <%@ taglib ...%> was required. Is it true ?
    thanks

    All you should need are the <%@ taglib %> and the jar files in your web-inf/lib directory.
    Nothing is required in web.xml for it to work.
    Make sure you are using the JSTL 1.1 taglib URIs though: http://java.sun.com/jsp/jstl/core.
    They look a lot like the old ones, but include /jsp now as well.
    Does the EL evaluate inside a tag? eg <c:out value="${application.servletContextName}"/>
    Couple of things to try
    EL evaluation may be disabled: Put this at the top of your page:
    <%@ page isELIgnored=false %>
    Check your web.xml for something like this (disables EL in pages)
    <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>true</el-ignored>
    </jsp-property-group>
    What version of the DTD are you using for web.xml? According to the JSP spec, if it is less than 2.3, and you haven't specified handling of the EL, it is ignored.
    Relevant bits of the JSP2.0 spec: JSP3.3.2, JSP 1.10.1
    Can you post some code which isn't working?
    Cheers,
    evnafets

Maybe you are looking for

  • Toshiba 39L4333DG - Cloud TV does not work

    I setup my TV, I made a firmware update but Cloud TV Service is NOT available. When I push either Cloud Home button or Search Portal button or Premium Apps button I get the same Premium Apps screen. In that screen ONLY Tools are working. Internet bro

  • Windows Update on Windows 7 (x64) on boot camp fails

    Running Windows 7 x64 on Boot Camp and trying to install an "important" update from windows update, but it fails: Update for Windows 7 for x64-based Systems (KB2506014) - Published: 4/12/2011. I received error code 80073712 and ran System Update Read

  • SAP R/3 and SAP Netweaver: changes, advantages and disadvantages

    Hello, i am interested in SAP R/3 and SAP Netweaver. Are there existing articles which describe in detail the architecture of both systems and improvements of the new system. I want to know which changes the developers made an why they did it? What a

  • Item text in output

    Hi Friends, How to get item text in output (Smartform), which is maintained at Sales order Item Level - Text Tab aginast a line item. Pls reply me the table name and fielnd name. Text is maintianed almost 20 words (100 Char) Srikky.

  • Display as Text: Source or computation/process?

    I have a bunch (about 10) of Display as Text (does not save state) items on a page. The source for all these items is a single row in some table. I see 2 alternatives to populating these items 1. Specify the Source attribute for each item as the SQL