This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dealing with client-side changing of code  RSS feed

 
tc kolii
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
    • 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
    Author and ninkuma
    Marshal
    Posts: 66208
    151
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • 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
    • 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
    Author and ninkuma
    Marshal
    Posts: 66208
    151
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • 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?
     
    Stefan Evans
    Bartender
    Posts: 1836
    10
    • Mark post as helpful
    • send pies
    • 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
    • Quote
    • Report post to moderator
    Thanks a lot Stefan for your help! I will try with ajax call.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!