How to do the hyperlink in JSP?

Hi,
I have a category jsp page which select category name from database.
<%
  CategoryEntity CurCategoryEntity = new CategoryEntity();
  CategoryItem[] AllCategory = null;
  AllCategory = CurCategoryEntity.GetCategoryList();
  if(AllCategory==null)
    out.println("No category in our system!");
  else
    String ReferenceURL = "/servlet/category.CategoryServlet";
    int CategoryListSize = AllCategory.length;
    for(int i=0; i < CategoryListSize; i++)
      String CategoryName = AllCategory.getCategoryName();
out.println("<font size=2><font face=Verdana, Arial, Helvetica, sans-serif>" + CategoryName +"</font></font><br><br>");
%>
The for loop statement lists out all category names in category table of DB.
e.g.
Adventure
Cooking
Music
Travelling
Dancing
How can I make the hyperlink on them in the above for loop statement? And, how can the user clicks the "Cooking" category, all products under "Cooking" will list out?
How should the jsp pass the valuable and how should the servlet handle it and pass it to entity?
Any free online tutorial?
Thanks

Hi,
The first one works fine, but the second PrepareStatement throws Exception.
javax.servlet.ServletException
     at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
     at org.apache.jsp.Productlist$jsp._jspService(Productlist$jsp.java:118)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
     at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
     at java.lang.Thread.run(Thread.java:536)
What's wrong with my code? I did replace the '?' with item in the SQL statement.
Thanks for help.

Similar Messages

  • How to retain the hyperlinks when converting Word doc to PDF?

    For adobe acrobat 9 pro, I can't figure out how to keep the hyperlinks working. If I create pdf from word doc by save as, it can't embed fonts, but links work. If I use "print" in word, it embeds fonts, but some hyperlinks didn't work. What to do to keep fonts embedded and links working? It drove me crazy! HELP!!!

    Depends on the version of WORD. With OFFICE 2007, go to the Adobe menu and select Create PDF (this is PDF Maker). That will save the links. A similar process is needed for OFFICE 2003. With OFFICE 2010, you will have to upgrade to AA X or add them in Acrobat manually.

  • How to enable the EL in jsp page

    hi can u tell 'how to enable the EL in jsp page'?

    *I am getting below exception in tomcat when i inclued +<%@ page isScriptingEnabled="true" isELEnabled="true"%>+*
    org.apache.jasper.JasperException: /index.jsp(1,1) Page directive has invalid attribute: isScriptingEnabled
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
         org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:311)
         org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)
         org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Validator.validate(Validator.java:1700)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • 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

  • How to bring the hyperlink in a JLabel object ?

    How to bring the hyperlink in a JLabel object ?
    I tried the following--> [ this is a sample ]
    JLabel label;
    label=new JLabel("<HTML><A HREF='file://D:/Examination/calc.exe'>Calculator</A></HTML>");Using this JLabel object in an JDialog the label comes perfectly with such a look of the hyperlink
    [ Blue coloured and underlined ] that's all !!
    It doesn't work anything that it should do.
    While all the html tags work perfectly in java then why the hyperlink in label doesn't ?
    If you have an idea then please send me the code.
    Thanks!

    see JXHyperLink at https://swingx.dev.java.net/
    Yeah, I looked at this. I agree with the other guy who said that all this does, presumably, is change the color of the text when the button is getting mousedover. That doesn't solve anything.
    As far as JEditorPane, it has its bad points and ... well, mostly bad points. However that's not really fair. JEditorPane was not designed to be on the level of an IE or FireFox.
    The BEST thing to use JEditor's web browsing facilities on is for creating your own documentation and help pages for software you are developing. Here is a list of some of the things JEditorPane does not come equiped with (as of 1.4 I haven't tried playing with it in 1.5):
    1. Form submission, PUT, and GET
    2. Download status
    3. Caching
    4. Cookies
    5. Plugins (ie Java, Flash, Quicktime)
    6. No javascript.
    Beyond that it is extremely brittle in parsing the HTML, and if the HTML is not totally well formed (and many pages are not) you won't get anything

  • How to sort the data in JSP using stylesheet sorting?

    Hi, i extracted data out in and display them <%=data%> in the jsp, but how to sort? do i have to provide a drop down list that gives different sorting options, and when user clicks on one option, say sort by title, the collection of results are sorted out on the same jsp page? so all in all, only one jsp page is needed or do i need to create xml files, etc?
    i have no idea how to integrate the xml sorting into the jsp page, even after seeing online help, cos there is no example of a jsp page with sorting to refer to. PLease help, thanks alot!

    im getting the data from beans, but one of the requirements was that i cant use the database to sort and display but i have to use xslt to do the sorting in the jsps, so i have no idea how to do so. possible to give an example? thanks

  • How to retrive the List in jsp

    Hi
    i m storing the objects of the same class in the List. and that list i stored in a request scope in the Acton class . Now i want to acess the single object from the List in jsp page ...
    so please suggest me ; how can i access it ? and i also dont want to use any scriptlet code
    i want to access it through jsp or html tags .....

    Try this (assuming you have the list in request scope as variable myList)
    <c:forEach var="listItem" items="${ requestScope.myList }">
    <c:out value="${listItem}"/> </td>
    </c:forEach>

  • How to halt the execution of JSP page..

    Hello all,
    I want to halt the execution of JSP page suppose for 10 seconds
    can anyone tell me how to do this
    Thanks
    Uttam

    ok
    thanks
    but this code will refresh the page after every 10 seconds.
    what i want that when click on a button on a page it will wait for 10 seconds
    then it should get refreshed only once i mean whenever i click on button
    not in ever 10 seconds
    thanks
    Uttam

  • How to retrieve the hyperlink source/destination for an image

    Hi
    I am using Indesign CS4 on windows. I am trying to make my way learning InDesign via the SDK documents. However I am not able to understand how I can do the following
    In InDesign I have placed an image and using the "interactive" menu added an hyperlink to the image. Now, in my code, given the itemRef for the image, how can i get the hyperlink associated with it?..
    I could probably go through the HyperlinkTable and loop through all the hyperlink lists to co-relate which image in my document has the hyperlink.
    However what I want to do is given the itemRef of my image, how do i get hyperlink associated with it
    thanks for your help
    --Sam

    Yes, I could of course filter the image myself (I'm using my own modifed version of the ACME GifEncoder to save the image, so that I could even do it during the encoding without ImageFilter). So my problem could be reduced to reduce an array of more than 255 colors to 255 colors by eliminating colors which are very near from each other.
    The point is that I don't have any algorithm to make an efficient color reduction with error diffusion like every graphic software would do. I would have imagined that such a standard algorithm would be somewhere in the JAVA API. If not, I'm gonna have to invent and implement my own algorithm...
    Yannick

  • How to get the querystring in jsp

    hi guys
    plz help me,
    how to get the query string in jsp page, is there any methods for getting querstring like getString() getParameter() ?

    C:\Documents and Settings\Administrator\ven\build\generated\src\org\apache\jsp\getcustomer_jsp.java:62: getQueryString() in javax.servlet.http.HttpServletRequest cannot be applied to (java.lang.String)
    i am getting error like this , if i used that method, shall i import any packages?

  • How to deactive the hyperlink for product

    In quotation,item level
    for each item,there's hyperlink for the product.
    For some reason,we don't want the user to enter the material master data.
    Then how could I deactive the hyperlink.
    Thanks
    Best regards,
    JiaoQian

    Hi,
    If you want deactivate the hyper link of product , Press f2 on that field and take the component name , then goto component workbench T code  as BSP_WD_CMPWB and enter the component name
    Go to the VIEW next, go to Context Node ,Then select the attribute , then expand the getter and setter methods .
    select the Get_p method then check the property of that attribute
    iv_property holds the property comment the one which you don't need.

  • How to remove the Hyperlink in smartform

    Hi Guys,
    In my smartform, one of the filed having the Hyperlink, i could not find it hyper link.
    Please provide me steps to remove the Hyperlink.
    Thanks,
    Gourisankar.

    Use the 'reset formats' button...

  • How to get the size of JSP html output?

    Hi,
    Is there a JSP method to get the size of JSP HTML output.
    e.g. I would like to print the size of the JSP e.g.
    Size of this page is <%=pageContext.getPageSize()%> Kb ???
    Any ideas? Thanks.
    George
    Edited by: googchro on Jan 5, 2010 4:45 PM

    Would you like to print "the size of this page is..." before or after you calculate the size of the page.
    Because adding that bit of text to the page will make the page bigger...
    Doing it in java, the best approach would probably to have a filter counting the number of bytes that gets sent to the writer/output stream.
    A client side tool measuring the amount of bytes received would probably be easier though.
    You can always look at the Content-length header sent with a response. Though you normally don't have access to that on the java/jsp side, as it is sent by the container.
    cheers,
    evnafets

  • How to define the hyperlink command in the online help to go to a specific place on another page?

    Hi,
    I run my online help (WebHelp) in an application in Firefox. When clicking a link on a page, I want to go to a specific section on another page. In the hyperlink I am using the #<bookmark> to go to the bookmark on the other page. This works in IE, but not in FireFox. Do I need to use a different command or do I have to change some settings in my browser to make it work?
    Thanks!

    Does your page design use frames (classic frames or inline frames)?
    From past threads:
    Make sure your bookmark doesn't contain a #. In other words, if the bookmark is Chapter1, Firefox will require #Chapter1 on the link, but if the bookmark is #Chapter1, then Firefox will require ##Chapter1 on the link.
    If your page changes height after loading, for example, you use a script that collapses some sections, Firefox may go to the original location in the page instead of the updated location. The workaround for this would be to have a script in the page check the hash and scroll to the correct location after changing the height.

  • How to set the hyperlink in the label setText Method

    Plz help me on this ..
    I want to make a hyperlink on a label.as the 'about eclipse' window in eclipse
    Is it possible to create a string which carry's with the html tags and make use that string in setText method of a Label in java?
    Thx
    rob

    I have already seen these pages but tells to use JLabel.
    But in my project a lot of code has been with respect Label.
    And as per the label only the call is invoking
    So I would like to make the hyperlink only in label and not in JLabel and other easy ways
    Label setText only takes string format as argument
    So can i make a string variable which holds the hyperlink in it and call in label's setText method.
    thx
    rob.

Maybe you are looking for