Advertisement

03.12.2004 at 06:39AM PST, ID: 20916764
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Using HTMLEncode in Java with  JSP

Asked by jvoros1 in Web Languages/Standards

Tags: , ,

Hello Expert I was wondering if you could help me I need to be able to display quotes and double quotes in my textbox on my jsp page, I ran into problems so i found out i can use HTMLEncode but  i need to be able to pass a value to my java and display it back on my jsp page. I was wondering if you can help me here is what i have so far.


//Source from http://ocw.mit.edu/NR/rdonlyres/Health-Sciences-and-Technology/HST-950JMedical-//ComputingSpring2003/D7B87450-BD26-4DA5-9696-DCBD2BEFFA81/0/entity_java.txt

htmlencodes.java

package edu.conestoga.admin.news;
import java.text.*;
import java.util.*;

public class htmlencodes {

 private static final char c[] = { '<', '>', '&', '\"'};
 private static final String expansion[] = {"&lt;", "&gt;", "&amp;",
                                     "&quot;"};
 public static String HTMLEncode(String s) {
      StringBuffer st = new StringBuffer();
      for (int i = 0; i < s.length(); i++) {
          boolean copy = true;
          char ch = s.charAt(i);
          for (int j = 0; j < c.length ; j++) {
            if (c[j]==ch) {
                st.append(expansion[j]);
                copy = false;
                break;
            }
          }
          if (copy) st.append(ch);
      }
      return st.toString();
    }
}

then my jsp page is as follows:

<%@ include file="../include/constants.jsp" %>
<%@ page language="java" %>
<%@ page import="edu.conestoga.admin.news.htmlencodes" %>

<%                    
      int NewsID = Integer.parseInt((String) request.getParameter("NewsID"));
      String Title = (String) request.getParameter("Title").trim();
      String users = htmlencodes.HTMLEncode(testing);
%>      

  <table border="0" bordercolor="#111111" width="600"  height="770">
      <tr>
                      <td width="37%" height="22"><b><font face="Trebuchet MS" size="2">News Title</font></b></td>
            <td><% out.println(HTMLEncode('<%=Title%>' ))%></td>
               </tr>
  </table>
but this code does not work can you help me please.
Start Free Trial
 
Loading Advertisement...
 
[+][-]03.14.2004 at 11:10AM PST, ID: 10592979

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Web Languages/Standards
Tags: htmlencode, java, jsp
Sign Up Now!
Solution Provided By: mreuring
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32