• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dealing with client-side changing of code

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have any issue with all my jsp's. In my jsp we have some validation and iff any field is left blank, it will send error emails.
My issue is if some one deletes the fields using firebug and hit the send button then the error emails are sent.

These email are increasing day by day. Is there any one way we can hide the code in jsp. Or any option to stop this form submission.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't sound like it has anything at all to do with JSP. So it may in the wrong forum and certainly has a poor subject. I've taken care of the subject by changing to something more appropriate.

But before we can proceed any further we need much more detail. For example:
  • What do you mean by "deletes the fields using firebug "? If people are changing your pages on-the-fly then this a great example of why we can never trust client-side validation.
  • What's handling sending the email on the server? That's where you need to have better validation.
  • What do you mean by "hide the code"? JSP code is always "hidden". If you are talking about the HTML code sent to the browser, then no.
  •  
    tc kolii
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    May be i've not posted correctly. But I found a solution to resolve my issue. I got a new issue which is: I need to pass java-script variable to jsp variable. I know am thinking in wrong way as jsp is server side and javscript is client side.
    Is there any way we can do it this?
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    No.

    Read this article to understand why.

    If you need to get data from the client to the server, you need to make a request.
     
    tc kolii
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you for the article. I understand the issue. My question is am getting the javascript variable value. Now my concern is i've to assign the value to a java String variable. Is it not possible something like :
    <% String name = <script type="text/javascript">param</script>;%>
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Read the article again. It's obvious that that will not work. It's not even correct Java syntax.

    P.S. The time to be putting Java code in a JSP is long past. Scriptlets have been discredited since 2002. Do you not think it's time to catch up with modern techniques?
     
    Bartender
    Posts: 1845
    10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The only way that javascript (client) can communicate with the java/jsp on the server is to make an http request, and get back a response.

    You can do this via AJAX.
    There are multiple libraries/frameworks around now that can help you in this.





     
    tc kolii
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks a lot Stefan for your help! I will try with ajax call.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic