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 8462027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:03:12+00:00 2026-06-10T14:03:12+00:00

The following is form for create or upadte a Post object(I use the spring

  • 0

The following is form for create or upadte a Post object(I use the spring form tag also):

<sf:form method="<c:choose><c:when test="${post.id==0}">post</c:when><c:otherwise>put</c:otherwise></c:choose>" commandName="post">
    Title:<sf:input path="title" /><sf:errors path="title" /><br />
    Body:<sf:textarea path="body" cols="70" rows="6" /><sf:errors path="body" /><br />
</sf:form>

And when the post.id==0,it means that this post is to be created while the method of the form should be “POST”,otherwise it is updated and the method will be “PUT”.

But the above code will cause exception:

org.apache.jasper.JasperException: /WEB-INF/jsp/posts/_form.jsp (line: 5, column: 41) Unterminated &lt;sf:form tag

What’s the problem,how to fix it?


update:

for the action it should be :

<c:url value="/posts/" /> for create and 
<c:url value="/posts/${post.id}/" /> for update.

Then the finally action will be /appcontext/posts or

/appcontext/posts/1

update2:

For action I can use :

${post.id == 0 ? '/posts/' : '/posts/${post.id}'}

However,this note the ‘/’ in the url, it will be relatived to the host.

That’s to say,the form action will be:

http://localhost/posts

While I want it be:

http://localhost/context/posts

That’s why I perfer <c:url> which will add the context for me.

And I want this manner:

${post.id == 0 ? '<c:url value="/posts/" />' : '<c:url value="/posts/${post.id}"/>'}

Which does not work.

  • 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-06-10T14:03:14+00:00Added an answer on June 10, 2026 at 2:03 pm

    You use tags in the property of an other tag. The " is nested.

    Try this:

     <sf:form method="${post.id == 0 ? 'post' : 'put'}" commandName="post"
              action="${post.id == 0 ? './posts/' : './posts/${post.id}'}">
        ...
    
        <input type="submit" value="Submit" name="submit" />
        or
        <a href="#" onClick="submit();">submit with link and JavaScript</a>
    
     </sf:form>
    
    
     <c:url value="${post.id == 0 ? './posts/' : './posts/${post.id}'}" var="url">
     </c:url>
    
     <a href="${url}">Huhu ein Link</a>
    

    If you use ./ it will refer to the same path. You can also get the context path via request.getContextPath() in your JSP Page or Servlet.

    Take a look here.

    > ${post.id == 0 ? '<c:url value="/posts/" />' : '<c:url
    > value="/posts/${post.id}"/>'}
    

    This can not work too, it is also nested again. Please read the Java Tutorial.

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

Sidebar

Related Questions

I have the following form <form name=myForm id=myForm method=post enctype=multipart/form-data action=script.php> and this jQuery
I have the following HTML <form id=create_form name=create_form action= method=post> <input name=type id=type value=individuel
I have following HTML table: <form method=post action=update-table.php> <table class=table-data style=width: 960px;> <thead> <tr>
I have done the following form <% form_for @anexo, :url => {:action => create},
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have a strange one. Create a new form. Then add the following function
I have a simple form right now: <form action='<? echo $PHP_SELF;?>' method='POST'> Username:<input type='text'
i have an sql file of the following form: CREATE VIEW dbo.SomeView AS select
I have the following test: it should respond with a json object do xhr
I have the following form in a Struts2 JSP that contains some radio buttons.

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.