Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7000757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:42:48+00:00 2026-05-27T20:42:48+00:00

I’m trying to get my spring application working, following a guy who posted an

  • 0

I’m trying to get my spring application working, following a guy who posted an example with earlier spring version. I’ve been having many problems with his example so I’m not posting a link so as not to lead anyone else astray. Fighting through issues, I was able to get to the point where things are working. Somewhat. I have not been able to figure out the following two things:

  1. $(message) isn’t printing the message which is a bean of type String.
  2. <c:out value="${message}" prints the message but only if I add <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> to the jsp. I would assume that adding jtslview class to the resolver would be enough. It’s not. What’s wrong here?

setup

  Eclipse IDE for Java EE Developers    1.4.1.20110909-1818 epp.package.jee 
  Tomcat 7
  Spring 3 distribution (all jars in /lib)
  lib/jstl-1.2.jar

jsp in question

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Message View</title> 
</head>
<body>
    $(message)
    <br>
    message=$(message);
    <br>
    message=<c:out value="${message}" />
</body>
</html>

this prints the following. The message “bean” is clearly passed to the page.

$(message) 
message=$(message); 
message=Hello World from Spring MVC! 

web.xml

<web-app    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
        xmlns="http://java.sun.com/xml/ns/javaee"    
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    
        id="WebApp_ID" 
        version="2.5">    

        <display-name>Spring3MVC</display-name>    
        <welcome-file-list>        
            <welcome-file>index.jsp</welcome-file>    
        </welcome-file-list>     

        <servlet>        
            <servlet-name>spring</servlet-name>        
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>    
        </servlet>    

        <servlet-mapping>        
            <servlet-name>spring</servlet-name>        
            <url-pattern>*.html</url-pattern>    
        </servlet-mapping>

</web-app> 

spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

    <beans  xmlns="http://www.springframework.org/schema/beans"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    xmlns:p="http://www.springframework.org/schema/p"    
    xmlns:context="http://www.springframework.org/schema/context"    
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">     

    <context:component-scan base-package="com.helloworldexample.controllers" />     

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

controller (just in case)

package com.helloworldexample.controllers;

import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class MesssageController {


@RequestMapping("/hello")
public ModelAndView handleHello() {
    String message="Hello World from Spring MVC!";

    return new ModelAndView("messageView", "message", message);

}

@RequestMapping("/welcome.html")
public ModelAndView handleWelcome() {
    String message="Welcome in Spring MVC!";

    return new ModelAndView("messageView", "message", message);

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:42:49+00:00Added an answer on May 27, 2026 at 8:42 pm

    The syntax for the JSP expression language is ${some expression}. Not $(some expression).

    Each time you use a JSP tag, its tag library must be declared in the JSP. The fact that you configure Spring to use a JstlView has nothing todo with the possibility of using the <c> tags. It just configures Spring to perform appropriate actions before dispatching to the view.

    <c:out> should always be used to render a string, unless you’re absolutely sure that the string doesn’t contain any character that must be HTML-escaped. Not using it opens the door to attacks where a user could submit a text containing </html> or a piece of javascript code that would compromise your web site.

    Read the official tutorial about servlets and JSPs: http://docs.oracle.com/javaee/5/tutorial/doc/bnadp.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.