Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

detection

 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!!!
I am new here and new student.

I got a question here.

If I want to detect whether there is an illegal charater(inside red) - other than what is provided now. how do i have to do it? Thanks in advance.

<html>
<body>
<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

</body>
</html>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Question #1: why are you doing this in a JSP? Modern JSP should have no Java code.

Question #2: what is an illegal character? You haven't defined what that means.

Question #3: what have you tried so far? We'll help you with your code, but won't write it for you.
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question #2: what is an illegal character? You haven't defined what that means.

Ans 2: I mean having words like following.

out.println(i); asdf

having asdf @ out.println(i); which is illegal character for the loop(i mean).

Question #3: what have you tried so far? We'll help you with your code, but won't write it for you.

Ans 3: What I got so far is I am able to check the following 2 line having words like above.

1.for (int i=0;i<5;i++)

2.out.println(i);

But, when someone put asdf before and after { } it generate error. So, looking for a solution. thanks for quick replay though.

<html>
<body>
<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

</body>
</html>
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So in other words you want to find out whether the Java code in your JSP will compile correctly when you try to use it, right? And the answer is, as Bear said: Don't put Java code into your JSP in the first place. Then the issue doesn't arise.

 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is another issues...

I am trying to answer this for my exam.

I am checking user input error rather than what it should be as following lines

<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

There should be nothing rather than what is written, of course, variable and no can change.
Thanks.

I am lost
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I see. I thought you were looking for some programming tool which would tell you whether your JSP code would compile or not. But you just want a rule which you, yourself, can use? You want to look at some Java code and determine whether it will compile successfully or not?
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeap ... thanks...any suggestion or recommandation?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic