How to format code text in jsp
Hi I am creating a online quiz system, so student can go through the开发者_JAVA技巧 question and submit the answer. My question is something about C++ coding, so it will display a class code, then maybe student can spot the syntax error or write out the output. My question is that how to i store the question into database, I am using MySQL i was thinking will it overflow the range? And how do it format the code during display in webpage. Anyone who had experienced on doing oline quiz system can give me some suggestion? Thank You
If you are worried about overflowing the range, I suggest using the following TEXT
types (in MySQL) instead of VARCHAR
:
- TINYTEXT (maximum size of 256 bytes)
- TEXT (maximum size of 65535 bytes or 64KB)
- MEDIUMTEXT (maximum size of 16777215 bytes or 16MB)
- LONGTEXT (maximum size of 4294967295 bytes or 4GB)
You can also include character set on TEXT
type too.
As to display code in a web page, there's syntaxHighlighter. It's a javascript library that you can incorporate in your site. They have support for many languages, including C++.
Hope this helps.
To store sourcecode in Mysql, you can use varchar or TEXT.
To edit source code Online, I recommend markItUp. For displaying only (without edit) there may be simpler solutions.
精彩评论