Menu

#202 return as TextNode when processing jsp

v1.6
closed-fixed
5
2006-03-19
2006-03-08
starfeng
No

I know the main function of htmlParser aims at the
html tag. but I know it also privded the support to
jsp flag, just, it seems many defects exist in the
processing to jsp.

for example, my jsp as follow:
<%
// it's my comment
%>
<input type=<%= typeName%> value=1>
HTMLParser can't parse them correctly, in fact,
there's two tags in this file.
I debug the source code "org.htmlparser.lexer.Lexer"
and find method "parseJsp(int start)" doesn't process
such a situation.

I guess the following codes can be added to
method "parseJsp",

switch (state) {
...
case 2:
...
case '/': // // or /*
ch = mPage.getCharacter (mCursor);
if (ch == '/') {
// find the \n or \r
while(true) {
ch = mPage.getCharacter (mCursor);
if (ch == Page.EOF) {
done = true;
break;
} else if (ch == '\n' || ch == '\r') {
break;
}
}
} else if (ch == '*') {
char ch2 = mPage.getCharacter (mCursor);
while (true) {
ch = ch2;
ch2 = mPage.getCharacter (mCursor);
if (ch == Page.EOF) {
done = true;
break;
} else if (ch == '*' && ch2 == '/') {
break;
}
}
} else {
mCursor.retreat();
}
break;

besides, method "parseTag(int start)"
switch (state)
{
case 0:
...
if (ch == '<') {
call nextNode() to process <input
name=<...>>
}

Discussion

  • Derrick Oswald

    Derrick Oswald - 2006-03-19

    Logged In: YES
    user_id=605407

    Handle single and double line comments within jsp nodes.
    Second suggested alteration to handle jsp tags within tag
    attributes wasn't implemented.

     
  • Derrick Oswald

    Derrick Oswald - 2006-03-19
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB