How to use List String in JSP page?

Hello All,
I am having problem using List<String> in my JSP page. Below is my JSP code.
<%@ page import="java.util.*, java.io.*"%>
<html>
<body>
<h1 align="center">Beer Recommendations JSP</h1>
<p>
<%
List<String> beerBrands = (List<String>)request.getAttribute("styles");
Iterator<String> it = beerBrands.iterator();
while(it.hasNext()){
     out.print("<br>try: " + it.next());
%>
</body>
</html>
When I compile the above JSP code in Eclipse 3.4 (using JBoss 4.2 as my Application Server), I get the following Warning.
Type safety: Unchecked cast from Enumeration to Enumeration<String>
If I add the "@SuppressWarnings("unchecked")" to the code, Eclipse does not give any Error during compilation. But, at runtime, I get the following Error.
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 10 in the jsp file: /BeerAdvice.jsp
Syntax error, annotations are only available if source level is 5.0
7: <p>
8:
9: <%
10: @SuppressWarnings("unchecked")
11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
12: Iterator<String> it = beerBrands.iterator();
13: while(it.hasNext()){
An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
The type List is not generic; it cannot be parameterized with arguments <String>
8:
9: <%
10: @SuppressWarnings("unchecked")
11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
12: Iterator<String> it = beerBrands.iterator();
13: while(it.hasNext()){
14:      out.print("<br>try: " + it.next());
An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
Syntax error, parameterized types are only available if source level is 5.0
8:
9: <%
10: @SuppressWarnings("unchecked")
11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
12: Iterator<String> it = beerBrands.iterator();
13: while(it.hasNext()){
14:      out.print("<br>try: " + it.next());
Any help is very much appreciated.
Thank you for your help.
Thanks,
Chubha

Hi anotherAikman,
Thank you for your help. I currently have the following version of the Java.
{color:#800000}java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
{color:#000000}{color:#000000}Does it mean I have Java SE Version 6 Update 17 and you are suggesting me to download the Java EE Version 6?{color} If this is correct, can you please let me know what difference does it make?
I am now going to install the Java EE 6 and try this out.
Thank you for your help.{color}
{color:#000000}Thanks,
Chubha{color}
{color}

Similar Messages

  • Oepe-12.1.2.1-kepler how to use ADF Templates in JSP page

    Hi all,
        I use oepe 12.1.2.1 kepler 4.3 and creating JSP page but I can't see any ADF Rich Faces Page in JSP Templates Page of Preferences Dialog. How to use ADF Templates in JSP page?
    Thanks,
    Thomas

    Select the JSP Templates link. Is the ADF Rich Faces Page template listed? Refer Creating the Login Page/4.
    Introduction to the Oracle Enterprise Pack for Eclipse (OEPE) IDE

  • How to use Session scope in jsp page

    Hello, I have login form, where user provides username and password. Then click on submit, it will forward to validation.jsp. Where it will check in database make sure username and password exit. Now i can also retrive accountid of perticular user. I want to put that username and accountid in session scope. so all other pages can use that username and accountid. How can i do that. I'm new at this, so please provide me example too. Here is my code for login.jsp and validation.jsp..
    Validation.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    //String name = request.getParameter( "username" );//
    //session.setAttribute( "accountID",accountID );//
    <%
    String connURL = "jdbc:oracle:thin:@orca.csc.ncsu.edu:1521:ORCL";
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    conn = DriverManager.getConnection(connURL, "vapatel","pjdas");
    stmt = conn.createStatement();
    String user=request.getParameter("userName");
    String password=request.getParameter("password");
    boolean entrance=false;
    stmt.excuteQuery("SELECT AccountID From Password WHERE USERNAME='"+user+"'");
    rs = stmt.executeQuery("SELECT * FROM Password WHERE USERNAME='"+user+"' AND PASSWORD='"+password+"'");
    while(rs.next()){
    String dbUser = rs.getString("USERNAME");
    String dbPassword= rs.getString("PASSWORD");
    if ((user.equals(dbUser)) && (password.equals(dbPassword))){
    entrance=true;
    if (entrance==true){%>
    <jsp:forward page="form.jsp"/>
    <%}
    else{%>
    <jsp:forward page="login.jsp"/>
    <%}
    %>

    hi,
    to put something into session scope in a jsp page use:
    session.setAttribute("counter", Integer.toString(5));to retrieve is from a jsp page use:
    String counterAttribute = (String)session.getAttribute("counter");

  • How to use messagebar tag in jsp page

    i am working with "messagebar" control presents in the htmlb controls.
    my aim is to display the message after pressing some button. how to give link for that.
    if anybody have smple code for it please send me with component,jsp page and bean(if used)......
    ragards,
    ajoy

    Hi,
    If I understood you right, then you want to update the message shown in your messgebar, when user clicks on button.
    To achieve this, have a MessageBar with no message text. And when ever a button is clicked in the event handling method of your button set message text to your messagebar.
    public void showMessage(String message, MessageType type) {
            messageBar.setMessage(type, message);
    public void onClick(Event event) throws PageException {
          showMessage("Clicked Button", MessageType.INFO);
    Greetings,
    Praveen Gudapati
    [Points are always welcome for helpful answers]

  • How to use extends attribute in jsp page directive

    Can anybody tell how to extend a existing .jsp file from another .jsp file. I have tried but it gives error.
    I have used Extends attribute of page directive as below:
    <%@ page extends = "MyAnotherJsp.jsp"%>
    I also tried : <%@ page extends = "MyAnotherJsp"%>
    I am using Tomcat as a web server
    Also tell where to put those files.
    Thanks.

    Hi I am using Netbeans 5.5, Sun Java System Application Server 9.
    ABC.java
    package javapackage;
    public class ABC{
    public String show(){
    return "Sandip Gaikwad";
    index.jsp
    <%@ page extends="javapackage.ABC" %>
    <html>
    <head>
    <title>JSP Page</title>
    </head>
    <body>
    <h1>JSP Page </h1>
    </body>
    </html>
    Above code throws following exception at runtime:-
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    Server log
    StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,<nulltype>,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:94)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:384)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:461)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:528)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:412)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:318)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    If I delete the line <%@ extends="javapackage.ABC"%> it works fine. Please tell me what is wrong with this line.

  • How to use java class in jsp page of JSPProvider?

    Hello everybody.
    I created simple JSPProvider channel with portal amconsole and named it "jspprov1". Then I created "jspprov"1 directory under "/ets/opt/SUNWps/desktop/sampleportal". I put "index.jsp" in it. And it worked until I add this line into "index.jsp": <% @page import="jspprov1package.aclass1" %>. Then I created directory "jspprov1package" under "/ets/opt/SUNWps/desktop/classes" and put "aclass1.class" into it and into "/ets/opt/SUNWps/desktop/classes" itself. I created "aclass1.class" on the other machine (with no installed portal) in j2sdk1.4.1_02: "javac aclass1.java". The text of this class is simple:
    "package jspprov1package;
    public class aclass1{
    public int int_field = 10;
    But the page still don't work. It writes on the portal desktop "ERROR: Content is not available".
    Does anybody know why this happened?

    Sorry, there were mistakes in jsp page and java files.
    I maked the channel "show exceptions" and found them out.

  • How to use attachemnt fucntion in JSP page using Attachemnt functionality ?

    Hi all
    I would want to know is any body worked attachement functionality to add attachements in sshr functions.I would want to add one attchement to my SIT which i created in core HR .But i need to add attachements in SSHR for these SIT.Would appreciate if anybody can throw some light on these area.Your suggestions are greatly appreciated.
    Cheers
    Kumar

    Hi Kumar
    I don't think that the attahcment functionality in SSHR links in with the attachment functionality in core! The SSHR attachments are attached to the workflow records and are usually to give the approver some more information to help the approval process.
    SSHR attachments usually get set in the review page, and this may not always equate to a single form in core.
    So, I don't think you will be able to do what you are trying to do.
    Regards
    Tim

  • How to pass parameter to intro.jsp page ?

    Hi all,
    Anybody please tell me how to pass parameter to intro.jsp page.
    Is there any param name defined in <forward > syntax ?
    I have made following configuration in struts-config.xml file.
    I want to pass parameter to intro.jsp page
    <global-forwards>
              <forward name="invalidsession" path="/intro.jsp" redirect="true" />
    </global-forwards>
    please reply soon.
    Thanking you.

    Hi all,
    I have a similar kind of question..
    Iam trying to pass a string variable from JSP to servlet thro URL..
    Im using tomcat5
    COde:
    String fname=request.getParamter("filename");
    <jsp:forward page="/servlet/coreservlets.filedownload?name=" +fname />
    It is generating a unterminated tag error..Please help..

  • How to use bean:write inside jsp:include ?

    I got a problem about JSP's syntax. The following is my code:
    <%@ include file="<bean:write name="HelloForm" property="target" />"%>
    The double quotes inside bean:write is my problem. Could you please teach me how to use bean:write within JSP's include? Thank you!

    http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html
    Include Directive vs <jsp:include>
    The include directive <%@include %> is done at page translation/compile time.
    It effectively pastes in a static file, and then compiles the JSP as if it was all one file.
    As such, you cannot provide a runtime expression to it.
    To do runtime inclusion, you need to use the <jsp:include> tag which does except runtime parameters.
    <%String test = request.getParameter("pageInfo");%>
    <%String link = test + ".jsp"; %>
    <jsp:include page="<%= link %>" %>Unfortunately you can't use the tag with a bean:write tag as well, you can only use runtime expressions, not tag. So you have to do the include with
    <jsp:include page="<%= HelloForm.getTarget() %>" />
    Cheers,
    evnafets

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • How to Hightlight the Data in Jsp Page

    How to Hightlight the Data in Jsp Page,
    I am doing doing search page,based on values given search page those are sent to servlet,in servlet based on some conditions if particuler id i am getting then i am redirecting to Respective jsp page with highlight the data from database..
    Thanks in advance...

    "Highlighting data in JSP sounds strange".
    Without looking at your search specific algorithms I feel you are finally going to display a page (HTML content) to user which contains highlighted text. Highlighting is not directly related to server side language you use (JSP, ASP, PHP etc.). This is purely HTML and CSS. However, server side script (such as JSP) should generate HTML content for getting highlight effect.
    Following HTML shows highlighted text using background-color property on span element.
    <html>
      <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      </head>
      <body>
          <p style="font-size:1.1em">This is a long paragraph which contains <span style="background-color: yellow;">highlighted text</span> and non highlighted text.</p>
      </body>
    </html>Thanks,
    Mrityunjoy
    Edited by: mrityunjoy on 14 Jun, 2010 3:30 AM

  • Using JavaBeans in a JSP Page

    I wan't to know the advantages and disadvantages of using JavaBeans in a JSP page.
    Like for example general traditional approach for a database connection
    is to create a connection and access the database from that and close the connection
    at the end of the page, instead of the If I use a common connection bean for making connections,
    is that suggestable and then when should i close the connection then.
    One good application of JavaBeans is using a Set and Get methods for form fields in
    a registration form to get back the values.
    So may i know how best can we use the JavaBeans other than this application.
    ThanX in advance,
    kiran
    [email protected]

    I believe putting processing and query code in the JavaBean was one of the reasons for putting JavaBeans support in JSP in the first place. The original idea was to use the setXXX methods to populate the bean's data from the posted form, then do the processing (or database query), then use the getXXX methods to display the bean's data.
    Efficiency-wise, it's exactly the same as putting all the code in-line in the JSP page (actually, it might be a bit slower, because of the reflection required to do it.) Code-wise though, it makes the JSP easier to read.
    Of course, we have EJBs now too, which tie very closely and can match database queries almost one-to-one, one way to incorporate these is inside the JavaBean you reference from the JSP, another way from a servlet you redirect the JSP to, etc...

  • How to use  SSL Technology in JSP.

    Can anybody Tell me that How to use SSL Technology in JSP ?
    I am using Apache Tomcat 5.0.28 Server.
    How to configure the Tomcat server so that it will access any web application supported by Tomcat via SSL ?
    Thank you very much in advance.

    The JSP does not need to know that the request is coming over SSL. If the application must be over SSL, but the server also allows non-SSL communication, then, like I said, you need to build in a Filter that will check if the incoming request is an https or http request and redirect to the https url if the request was http. And you can do that using the method listed in the previous post. As far as setting up the SSL certificate for Tomcat to use, refer to the Tomcat Documentation that comes with the server. Other than those two things, you don't need to know anything else about SSL inorder to run an SSL application through a Tomcat server (or any other enterprise server either, for that matter), but do an internet search for SSL and maybe one or two other keywords that apply to your situation and you should find plenty that will help.

  • How to use custom tag in jsp

    sir
    plz tell me how to use custom tag in jsp.plz describe it.
    i will be thankful to u

    Do you want to use taglibs or develop custom tags? Either way take a look at these:
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags.html
    http://www.stardeveloper.com/articles/display.html?article=2001081301&page=1
    http://www.onjava.com/pub/a/onjava/2000/12/15/jsp_custom_tags.html
    http://jakarta.apache.org/taglibs/tutorial.html
    http://www.ibm.com/developerworks/edu/j-dw-java-custom-i.html
    http://www.herongyang.com/jsp/tag.html

Maybe you are looking for

  • Student CS6 on pc and mac?

    I have a student license. Can I install on more than one computer? My pc(win7) is dying and I want to install on my macbook(10.8), but I'm getting an  error that my serial number is wrong. Is this because I have to  deactivate my other copy? I have c

  • F5A244

    Hi All, When i am posting a cash journal ,i am facing following error. ' try again' and wheni click on the long text , there is a msg no F5A244. What is this message.? Its urgent. Thanks in advance. Regards, Vikas.

  • ITunes doesn't stream to airport express remote speakers

    Hi, Since I updated iTunes (v8.0) I can't stream audio to my remote speakers via airport express. The remote speakers are visible in iTunes, I can select them but airtunes can't connect. I don't get an error message, after a few seconds iTunes plays

  • FMS license key

    Hi Can we use same license key for more than one FMS server? If we use one key for other server then what will be the effect on the FMS. Also one more think can we use one license key of one version to other version? For example can we use license ke

  • Find my Unanswered questions

    Should show up under your profile - Activity